schielrn
Well-known Member
- Joined
- Apr 4, 2007
- Messages
- 6,941
Ok this has something to do with Excel, so I thought it was applicable to post here. I am trying to create a vbScript that will take all Excel files in a folder and save them as a pdf as well.
The commented line is not working in the script and I cannot for the life of me figure out the syntax to get it to work. I know thisFileName is correct because of the message box. The script will just not run if I uncomment the line in red, but that is the exact syntax in Excel?
I know I could do this through Excel, but was just hoping to have a script that could easily be kicked off.
Just thought I'd check if anyone here had an idea before I went to the all Excel approach.
Thanks for any help anyone can give.
The commented line is not working in the script and I cannot for the life of me figure out the syntax to get it to work. I know thisFileName is correct because of the message box. The script will just not run if I uncomment the line in red, but that is the exact syntax in Excel?
I know I could do this through Excel, but was just hoping to have a script that could easily be kicked off.
Just thought I'd check if anyone here had an idea before I went to the all Excel approach.
Rich (BB code):
Set xlObj = CreateObject("Excel.Application")
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("M:\Macros and Stuff for GL\New Folder")
For Each file In f.Files
set xlWB = xlObj.Workbooks.Open(file)
thisFileName =Left(xlWB.FullName , InStrRev(xlWB.FullName , ".") - 1)
xlWB.Sheets.Select
msgbox(thisFileName)
'xlWB.ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= thisFileName & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
xlWB.close False
counter = counter + 1
WScript.Echo "File " & counter & " of " & f.Files.count & " Done"
Next
xlObj.quit
Thanks for any help anyone can give.