Print-to-PDF is corrupted in WIN11

zombiemaster

Board Regular
Joined
Oct 27, 2009
Messages
245
Hoping someone can help. I'm testing some macros for our upcoming upgrade from WIN10 32-bit to WIN11 64-bit and have run into an issue with one of them.

This macro scrapes user-input data from one spreadsheet tab and pastes it into another tab with more formal formatting, then that formatted tab gets saved as a PDF to a location of the user's choice. The file name for the PDF is defaulted to a combination of the name and policy number in cells B17 and B7.

This has been working for years with no issues, but when I am running it in the WIN11 testing virtual machine, the PDF that gets saved is corrupted and won't open.

The code below is the section where it saves the file - does anyone see something that might be an issue? I would have thought that doing a "save as" would be pretty generic from WIN10 to WIN11...


VBA Code:
Dim sFileName As String
    
    With Sheets("WORK ITEM TEMPLATE")
       .Visible = True
       .Calculate
        sFileName = Range("B17").Value & " " & Range("B7").Value
        sFileName = Application.GetSaveAsFilename(InitialFileName:=sFileName, Filefilter:="PDF (*.pdf), *.pdf", Title:="Save Print Output As")
            If sFileName <> "False" Then
                .PrintOut Copies:=1, Collate:=True, PrToFileName:=sFileName
            End If

Thanks for any help as always,

-=ZM=-
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Apologies - I named this question "print to PDF" but it should have been "SaveAs PDF" is corrupted...my bad, and it looks like I can't fix the thread name after it posted. :(
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,195
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top