Home > other >  Excel vba development for help, step are not consistent with the result directly executed
Excel vba development for help, step are not consistent with the result directly executed

Time:09-20

VBA small white, try to write a small function, automatically adjust the print Settings of each sheet in Excel,

Due to zoom in the print setup and FitToPagesWide cannot be set at the same time, when the FitToPagesWide=1, zoom is false,
But need specific zoom value as a subsequent judgment, therefore, will FitToPagesWide change back to zero, step zoom value can be obtained after the other, but still executed directly to false, lead to can't judge,

O god, the code is as follows,

Sub macro (1) Application. PrintCommunication=False For p=1 To Sheets. The Count Sheets (p). The Activate With ActiveSheet. PageSetup. LeftMargin=Application. InchesToPoints (0.7). The RightMargin=Application. InchesToPoints (0.7). The PaperSize.=xlPaperA4 Orientation=xlPortrait. Zoom=100 FitToPagesWide=1. FitToPagesWide=0. FitToPagesTall=0 MsgBox (ActiveSheet. PageSetup. Zoom). If Zoom & lt; 100 Then FileSheet=. Zoom MsgBox (ActiveSheet. PageSetup. Zoom). Orientation.=xlLandscape FitToPagesWide=1. FitToPagesWide=0. FitToPagesTall=0 If. Zoom & lt; 100 Then MsgBox (ActiveSheet. PageSetup. Zoom). LeftMargin=Application. InchesToPoints (0.25). The RightMargin=Application. InchesToPoints (0.25) End If the End of the If. FitToPagesWide=1 End With Next p Application. PrintCommunication=True
End Sub
  • Related