Home > Software engineering >  About excel macro problem for help!
About excel macro problem for help!

Time:11-07

Sub Macro1 ()
'
'Macro1 Macro
'macro recording by cheung man-kwong, time: 2020/05/20
'

'
Application. EnableEvents=False
ActiveWindow. SelectedSheets. PrintOut From:=1, the To:=2147483647, Copies:=1, the Preview:=False, ActivePrinter:="", PrintToFile:=False, Collate: IgnorePrintAreas:==True, or False on
Application. EnableEvents=True
End Sub



This is recorded a print button macros, I want to change into a page on another sheet of macros, need to modify the function! Thank you all for the great god, now can only print the current page,

CodePudding user response:

Then you can record the entire process, from sheet1 click to sheet2, then print, look at the whole process of the generated code, can record different sheet and then a new page, click on the automatically generated code page should appear to choose sheet inside,

ActiveWindow. SelectedSheets.
Here said the current window selection sheet page, the change to the other, or get a choice before the action, such as: Sheets (" Sheet3 "). The Select,
Sheets (" Sheet3 "). The PrintOut From:=1
To try to press F2 see relevant members of the class structure,

CodePudding user response:

Will ActiveWindow. SelectedSheets. PrintOut... To ActiveWindow. Sheets (" to be printed sheet name "). The PrintOut... Instead, as: ActiveWindow. Sheets (" Sheet2 "). The PrintOut... ,

More Excel/VBA knowledge, pay attention to auspicious programming public,
  •  Tags:  
  • VBA
  • Related