Microsoft Excel Webinar

Results 1 to 7 of 7

Thread: Solved: Make a new folder error

  1. #1
    Moderator VBAX Guru Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    3,151
    Location

    Solved: Make a new folder error

    I am trying to make a new folder to hold VBA Examples on the New Apple I only just purchased.

    The supplied code contains a syntax error in the ninth line. It was copied from Ron deBruin's site and appears to be an accurate copy. All that I have altered is the actual path name required for the folder to be created in.

    VB:
    Sub MakeFolderIfNotExist() 
        Dim FolderString As String 
        Dim ScriptToMakeDir As String 
         'Make folder named VBAExamples on the harddrive
        FolderString = MacScript("return (path to harddrive folder) as string") & "VBAExamples:" 
         'Or enter the complete path
         'FolderString = "Macintosh HD:Users:Edward Eggleston:VBAExamples:"
        ScriptToMakeDir = "tell application " & Chr(34) & "Finder" & Chr(34) & Chr(13) 
        [COLOR=Red]ScriptToMakeDir = ScriptToMakeDir & "do shell script ""mkdir -p "" & quoted _ 
        form of posix path of " & Chr(34) & FolderString & Chr(34) & Chr(13)     [/COLOR] 
        ScriptToMakeDir = ScriptToMakeDir & "end tell" 
        On Error Resume Next 
        MacScript (ScriptToMakeDir) 
        On Error Goto 0 
    End Sub 
    
    
    Formatting tags added by mark007
    Remember To Do the Following....
    Use tags when posting code to the thread,
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  2. #2
    Instad of MacScript, have you tried MsgBox to make sure that all the sytanx is correct in the ScriptToMakeDir string?

  3. #3
    Moderator VBAX Guru Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    3,151
    Location
    Mike, I have fixed an error relating to the spaces between ""mkdir -p"" and this has resolved the syntax error message, but has now been replaced by the error message "expected end of statement" and highlights the word "form" in the same line.
    Remember To Do the Following....
    Use tags when posting code to the thread,
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  4. #4
    http://macscripter.net/

    has an AppleScipt forum that could help with AS syntax, etc.

  5. #5
    Moderator VBAX Guru Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    3,151
    Location
    Thank you
    Remember To Do the Following....
    Use tags when posting code to the thread,
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  6. #6
    you can't use a line continuation character in the middle of a string:
    VB:
    ScriptToMakeDir = ScriptToMakeDir & "do shell script ""mkdir -p "" & quoted _ 
    form of posix path of " & Chr(34) & FolderString & Chr(34) & Chr(13) 
    
    
    Formatting tags added by mark007
    should be
    VB:
    ScriptToMakeDir = ScriptToMakeDir & "do shell script ""mkdir -p "" & quoted" &  _ 
    " form of posix path of " & Chr(34) & FolderString & Chr(34) & Chr(13) 
    
    
    Formatting tags added by mark007
    Be as you wish to seem

  7. #7
    Moderator VBAX Guru Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    3,151
    Location
    Thank you
    Remember To Do the Following....
    Use tags when posting code to the thread,
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •