The following code snippet appears to change the papersize, but it does not “stick” with the report. The debug line with “save” seems to indicate that the report has the correct papersize, but immediately reopening the report shows that the papersize has reverted to its original setting. Occasionally it works when single-stepping through the code, but I haven’t found any bulletproof way for it to always work. What am I missing?
If vbYes = MsgBox(“Confirm you want to ” & vbCrLf & _
“change the report’s FormID to: ” & iPapersize, vbYesNo, “About to modify: ” & sReportName) Then
DoCmd.OpenReport sReportName, View:=acViewDesign
Debug.Print “Device: ” & Reports(sReportName).Printer.DeviceName
Debug.Print “open: ” & Reports(sReportName).Printer.PaperSize
Reports(sReportName).Printer.PaperSize = iPapersize
Debug.Print “assign: ” & Reports(sReportName).Printer.PaperSize
DoEvents
DoCmd.Save acReport, sReportName
Debug.Print “saved: ” & Reports(sReportName).Printer.PaperSize
DoCmd.Close acReport, sReportName, acSaveYes
DoCmd.OpenReport sReportName, View:=acViewDesign
Debug.Print “reopen: ” & Reports(sReportName).Printer.PaperSize
DoCmd.Close acReport, sReportName, acSaveYes
MsgBox “Done”
End If