Consulting

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
    4,997
    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.

    [vba]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)
    ScriptToMakeDir = ScriptToMakeDir & "do shell script ""mkdir -p "" & quoted _
    form of posix path of " & Chr(34) & FolderString & Chr(34) & Chr(13)

    ScriptToMakeDir = ScriptToMakeDir & "end tell"
    On Error Resume Next
    MacScript (ScriptToMakeDir)
    On Error GoTo 0
    End Sub [/vba]
    Remember To Do the Following....
    Use [Code].... [/Code] 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
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    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
    4,997
    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 [Code].... [/Code] 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
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    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
    4,997
    Location
    Thank you
    Remember To Do the Following....
    Use [Code].... [/Code] 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
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    you can't use a line continuation character in the middle of a string:
    [vba]ScriptToMakeDir = ScriptToMakeDir & "do shell script ""mkdir -p "" & quoted _
    form of posix path of " & Chr(34) & FolderString & Chr(34) & Chr(13) [/vba]
    should be
    [vba]ScriptToMakeDir = ScriptToMakeDir & "do shell script ""mkdir -p "" & quoted" & _
    " form of posix path of " & Chr(34) & FolderString & Chr(34) & Chr(13) [/vba]
    Be as you wish to seem

  7. #7
    Moderator VBAX Guru Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    4,997
    Location
    Thank you
    Remember To Do the Following....
    Use [Code].... [/Code] 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
  •