I have a document built out in excel that has up to 6 versions and I would like to save from 1 up to 6 at a time as a PDF using vba. I am having trouble setting up the file name. Below is the code I have written:
Versions is how many versions of the file to make, VersionNames is a string that contains the 6 names of the different versions of the document I would like to save.
For d = 1 To Versions
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
DesktopAddress & "\" & VersionNames(d) & " Type of File.pdf", Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=True
Next d
When I attempt to run the program, I get the following error:
"Run-time error '-21470 18887 (80071779)':
Document not saved.
Hitting debug highlights the above code in yellow. If I make VersionNames just one value it works perfectly, but it won't let me use specific parts of the array. Any suggestions for getting it to work?
Bookmarks