PDA

View Full Version : Solved: Make a new folder error



Aussiebear
04-29-2012, 03:44 AM
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.

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

mikerickson
04-29-2012, 02:04 PM
Instad of MacScript, have you tried MsgBox to make sure that all the sytanx is correct in the ScriptToMakeDir string?

Aussiebear
04-29-2012, 03:51 PM
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.

mikerickson
04-30-2012, 01:08 PM
http://macscripter.net/

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

Aussiebear
04-30-2012, 04:28 PM
Thank you

Aflatoon
05-02-2012, 04:53 AM
you can't use a line continuation character in the middle of a string:
ScriptToMakeDir = ScriptToMakeDir & "do shell script ""mkdir -p "" & quoted _
form of posix path of " & Chr(34) & FolderString & Chr(34) & Chr(13)
should be
ScriptToMakeDir = ScriptToMakeDir & "do shell script ""mkdir -p "" & quoted" & _
" form of posix path of " & Chr(34) & FolderString & Chr(34) & Chr(13)

Aussiebear
05-03-2012, 01:31 AM
Thank you