Everything works so far except trying to save the Excel workbook in the same folder with my created folders in the try.
Fairly new to Applescript so any suggestions to my code is very welcome
try
set jobName to text returned of (display dialog "Enter factory name:" default answer "")
set jobNum to text returned of (display dialog "Enter a batch number:" default answer "")
set tempName to (jobName & " " & jobNum)
set folderpath to POSIX path of (choose folder with prompt "Select client folder")
do shell script "/bin/mkdir -p " & quoted form of (folderpath & "/" & ¬
tempName & "/" & tempName & " ") & "{Files,Renders}"
end try
tell application "Microsoft Excel"
-- make new workbook
set newBook to make new workbook
save workbook as newBook filename tempName
-- save workbook as newBook in folderpath
tell worksheet "Sheet1" of active workbook
set font style of font object of row 1 to "Bold"
set horizontal alignment of row 1 to horizontal align center
set value of range "A1:C1" of active sheet to {"Item", "Qty", "Status"}
set column width of column 1 to 46 -- characters (columns)
set column width of range "b:c" to 20 -- characters (columns)
end tell
tell page setup object of active sheet
set page orientation to portrait
set zoom to false
set fit to pages wide to 1
set fit to pages tall to 3
-- set left header to "&R"
set left header to tempName
end tell
set destinationPath to folderpath
save workbook in destinationPath
end tell
I am getting this error; error “Microsoft Excel got an error: Parameter error.” number -50 on the save workbook line at the end.
I have it this far. I can rename the Excel file to the name & number I want.
Success!!!
I figured this out - The issue is saving the Excel file into the folderpath folder, not the folderpath itself
try
set jobName to text returned of (display dialog "Enter factory name:" default answer "")
set jobNum to text returned of (display dialog "Enter a batch number:" default answer "")
set tempName to (jobName & " " & jobNum)
set folderpath to POSIX path of (choose folder with prompt "Select client folder")
do shell script "/bin/mkdir -p " & quoted form of (folderpath & "/" & ¬
tempName & "/" & tempName & " ") & "{Files,jpegs,Renders}"
end try
tell application "Microsoft Excel"
set newBook to make new workbook
tell worksheet "Sheet1" of active workbook
set font style of font object of row 1 to "Bold"
set horizontal alignment of row 1 to horizontal align center
set value of range "A1:C1" of active sheet to {"Item", "Qty", "Status"}
set column width of column 1 to 46 -- characters (columns)
set column width of range "b:c" to 20 -- characters (columns)
end tell
set today to (current date)
tell page setup object of active sheet
set page orientation to portrait
set zoom to false
set fit to pages wide to 1
set fit to pages tall to 3
set left header to (tempName & " " & month of today & " " & day of today & ", " & year of today) as string
end tell
set workbookName to (tempName & ".xlsx") as string
set destinationPath to folderpath & workbookName
tell application "Microsoft Excel"
save active workbook in (folderpath & "/" & ¬
tempName & "/" & tempName & " ")
end tell
end tell
Thanks to your search and some other answers !!!
Model: iMac mid-2011
AppleScript: 2.5
Browser: Safari 537.36
Operating System: Mac OS X (10.10)
Just curious, does the script still work if you get rid of the tell…/end tell from around the save active workbook line? Think it should do because you’re already within a tell block.