OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 21-02-2010, 22:09
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default creating folder if folder doesn't exist

Hi.
I'm creating a folder if a folder doesn't exist and resuming macro. It seems to work fine on my machine but having trouble on other users machine and not sure why. It goes to line 005 (see code).

Here's a chunk of code clipped. Any ideas, suggestions, or better approach would be appreciated.

Code:
saveFold = frmMain.txtPath.Value

    
    If CorelScriptTools.FileAttr(saveFold) = 16 Then
        'do nothing
    Else
        Dim answ1 As Integer
        answ1 = MsgBox("Folder does not exist. Would you like to create it?", vbOKCancel)
        If answ1 = vbOK Then
            'create folder and continue
            Dim foldNew As String
            If CorelScriptTools.MkFolder(saveFold) Then
                'do nothing and continue with sub
                frmMain.txtPath.Value = frmMain.txtPath.Value & "\" 'add backslash.
                If Right(frmMain.txtPath.Value, 2) = "\\" Then
                    frmMain.txtPath.Value = Left(frmMain.txtPath.Value, Len(frmMain.txtPath.Value) - 1) ' remove double backslash
                End If
                saveFold = frmMain.txtPath.Value
            Else
'error 005
                MsgBox "Unable to create folder. Please check path and User Permissions", vbCritical
            End If
        ElseIf answ1 = vbCancel Then
            'exit sub
            Exit Sub
        Else
            'exit sub
            Exit Sub
        End If
    End If
    
    
    SaveSetting "myMacro", "Preferences", "path", frmMain.txtPath.Value
Thanks,
John
Reply With Quote
  #2  
Old 23-02-2010, 12:55
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,791
Blog Entries: 13
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Create Folder

This works fine for me, the folder is created. Maybe a permissions problem? You could try using MkDir instead, see if it makes a difference.

-Shelby
Reply With Quote
  #3  
Old 23-02-2010, 14:12
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

Hi,

I seemed to have fixed it using

Code:
If CorelScriptTools.FileAttr(saveFold) > 1 Then
instead. This works even if the user wants to use the desktop to save files, since the macro was trying to create the desktop folder.

Unfortunately mkdir was doing the same.
One problem was trying to make subdirectories which I found cannot be made with either function.

Thanks.
John
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Folder Check norbert_ds CorelDRAW/Corel DESIGNER VBA 2 13-01-2008 21:18
Browse for folder ddonnahoe CorelDRAW/Corel DESIGNER VBA 2 09-11-2005 18:44
List names of files located in a folder RVogel CorelDRAW/Corel DESIGNER VBA 1 31-03-2005 17:14
Browse for Folder shelbym CorelDRAW/Corel DESIGNER VBA 2 12-04-2004 18:13
Creating New Folder Haucer Corel Photo-Paint CS 1 23-10-2003 08:22


All times are GMT -5. The time now is 23:01.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com