Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-12-2016, 09:23 AM
mktate mktate is offline Print Multipage Userform in Landscape Windows 10 Print Multipage Userform in Landscape Office 2010 64bit
Novice
Print Multipage Userform in Landscape
 
Join Date: Dec 2015
Posts: 26
mktate is on a distinguished road
Default Print Multipage Userform in Landscape

I have a Word (not Excel) multipage userform (5 pages). One client wants to have "images" of each of the pages to write on by hand - yes really! I have a command button to print the entire userform with the following sub:

Private Sub CommandButton1_Click()
For i = 0 To 4
Me.MultiPage1.Value = i
Me.PrintForm
Next
End Sub

This of course prints each page in portrait rather than landscape and gets cut off. I could probably change my printer defaults, but for my clients who want to print, I need some code as they won't be able to change their defaults easily. Does anyone have VBA code to add to this sub to get each page in landscape? I am unable to use =wdOrientLandscape, etc., since we aren't talking about word docs; rather the userform itself. Thanks.
Reply With Quote
  #2  
Old 05-12-2016, 02:13 PM
macropod's Avatar
macropod macropod is offline Print Multipage Userform in Landscape Windows 7 64bit Print Multipage Userform in Landscape Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Sounds to me rather like you need to do something like a screen capture of the userform and paste it into the underlying document on a landscape formatted page.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 05-12-2016, 02:57 PM
mktate mktate is offline Print Multipage Userform in Landscape Windows 10 Print Multipage Userform in Landscape Office 2010 64bit
Novice
Print Multipage Userform in Landscape
 
Join Date: Dec 2015
Posts: 26
mktate is on a distinguished road
Default

I have seen some code for an Excel userform but doesn't seem applicable for a Word one.
Reply With Quote
  #4  
Old 05-13-2016, 01:56 AM
macropod's Avatar
macropod macropod is offline Print Multipage Userform in Landscape Windows 7 64bit Print Multipage Userform in Landscape Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

If you have code that prints a userform in landscape mode for Excel without pasting anything to a worksheet, the same code would almost certainly work in Word.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 05-13-2016, 09:00 AM
mktate mktate is offline Print Multipage Userform in Landscape Windows 10 Print Multipage Userform in Landscape Office 2010 64bit
Novice
Print Multipage Userform in Landscape
 
Join Date: Dec 2015
Posts: 26
mktate is on a distinguished road
Default Code that doesn't work

Here is Code I tried to change for a Word userform, using ActiveDocument instead of Application, but I get bugs virtually every line. I am not a coder, so then I tried to just delete what didn't have a home in a Word document, eventually getting multiple pages of the userform to print, but again in portrait, not landscape. So, if anyone can modify this code to try to get a multipage Word userform to print in landscape, I would greatly appreciate it! (I give the original code, not my attempted revisions):
Code:
Option Explicit
 
Private Declare PtrSafe Sub keybd_event Lib "user32" _
(ByVal bVk As Byte, ByVal bScan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As LongPtr)
Const VK_SNAPSHOT = 44
Const VK_LMENU = 164
Const KEYEVENTF_KEYUP = 2
Const KEYEVENTF_EXTENDEDKEY = 1
 
Private Sub CommandButton1_Click()
DoEvents
keybd_event VK_LMENU, 0, KEYEVENTF_EXTENDEDKEY, 0
keybd_event VK_SNAPSHOT, 0, KEYEVENTF_EXTENDEDKEY, 0
keybd_event VK_SNAPSHOT, 0, KEYEVENTF_EXTENDEDKEY + _
KEYEVENTF_KEYUP, 0
keybd_event VK_LMENU, 0, KEYEVENTF_EXTENDEDKEY + _
KEYEVENTF_KEYUP, 0
DoEvents
Workbooks.Add
Application.Wait Now + TimeValue("00:00:01")
ActiveSheet.PasteSpecial Format:="Bitmap", Link:=False, _
DisplayAsIcon:=False
ActiveSheet.Range("A1").Select
'added to force landscape
ActiveSheet.PageSetup.Orientation = xlLandscape
 
 
With ActiveSheet.PageSetup
  .PrintTitleRows = ""
  .PrintTitleColumns = ""
End With
 
ActiveSheet.PageSetup.PrintArea = ""
 
With ActiveSheet.PageSetup
  .LeftHeader = ""
  .CenterHeader = ""
  .RightHeader = ""
  .LeftFooter = ""
  .CenterFooter = ""
  .RightFooter = ""
  .LeftMargin = Application.InchesToPoints(0.75)
  .RightMargin = Application.InchesToPoints(0.75)
  .TopMargin = Application.InchesToPoints(1)
  .BottomMargin = Application.InchesToPoints(1)
  .HeaderMargin = Application.InchesToPoints(0.5)
  .FooterMargin = Application.InchesToPoints(0.5)
  .PrintHeadings = False
  .PrintGridlines = False
  .PrintComments = xlPrintNoComments
  .PrintQuality = 300
  .CenterHorizontally = True
  .CenterVertically = True
  .Orientation = xlLandscape
  .Draft = False
  .PaperSize = xlPaperA4
  .FirstPageNumber = xlAutomatic
  .Order = xlDownThenOver
  .BlackAndWhite = False
  .Zoom = False
  .FitToPagesWide = 1
  .FitToPagesTall = 1
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWorkbook.Close False
End Sub

Last edited by macropod; 05-13-2016 at 03:42 PM. Reason: Added code tags & formatting
Reply With Quote
  #6  
Old 05-13-2016, 03:51 PM
macropod's Avatar
macropod macropod is offline Print Multipage Userform in Landscape Windows 7 64bit Print Multipage Userform in Landscape Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

As I said in post #4, the code would work for Word if it didn't paste anything to an Excel workbook, but that's precisely what your code does. In fact, most of it is concerned with the worksheet formatting. As I also suggested you might need to do in post #2, the code basically does a screen capture of the userform and pastes it. For a single multi-page userform, that would take much less time to do manually than it would take for anyone to write the code. Is there a reason for not doing that?

FWIW, your code would only process the page of a userform it's attached to.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 05-13-2016, 03:59 PM
mktate mktate is offline Print Multipage Userform in Landscape Windows 10 Print Multipage Userform in Landscape Office 2010 64bit
Novice
Print Multipage Userform in Landscape
 
Join Date: Dec 2015
Posts: 26
mktate is on a distinguished road
Default

I appreciate that your reply reinforces what I already know - that this code will work for excel but not Word. I have no idea how to change it for a Word user form. I also realize the code is for a single page user form; however, as the initial question indicated, I have a multipage (5) user form, and had initial code to print all pages - but in portrait. I have NO IDEA how to modify the code to make it work with a Word document rather than an Excel document. I also indicated in my prior posts that this is being done for users of the user form and will be done more than once; therefore, it needs to be a command button in the form - it is not a one-time screen shot affair - and since I would need five screen shots anyway, I still cannot get there without modifying the code I have (or getting someone willing to help with this rather than just keep pointing out what I don't have).
Reply With Quote
  #8  
Old 05-13-2016, 04:03 PM
macropod's Avatar
macropod macropod is offline Print Multipage Userform in Landscape Windows 7 64bit Print Multipage Userform in Landscape Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Surely, once you've taken a copy of all the pages, you can save them as a template?! There would be no reason to keep doing this for the same form...
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 05-13-2016, 04:26 PM
mktate mktate is offline Print Multipage Userform in Landscape Windows 10 Print Multipage Userform in Landscape Office 2010 64bit
Novice
Print Multipage Userform in Landscape
 
Join Date: Dec 2015
Posts: 26
mktate is on a distinguished road
Default

I cannot get a copy of each of the pages - can you actually explain how to do this? As I said part gets cut off bc it is in portrait. Further, this is a dynamic form that changes depending upon answers. I have already provided them with a data sheet that can be saved but they would like actual pics of the form - easier to give to secretary if they have to make a new set of documents with similar responses. The userform can change dramatically depending.
Reply With Quote
  #10  
Old 05-13-2016, 05:05 PM
macropod's Avatar
macropod macropod is offline Print Multipage Userform in Landscape Windows 7 64bit Print Multipage Userform in Landscape Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Simply start your userform, switch to the page you want to copy, press Alt-PtrScr, close the userform, then paste the picture into Word. Not exactly difficult...
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Landscape Orientation - Rotate page so top of landscape is printed on left side swifty2010 Word 17 06-11-2022 05:50 PM
Print Multipage Userform in Landscape Convert large multipage table to jpeg idiotwind Word Tables 3 12-01-2015 03:53 AM
Print Multipage Userform in Landscape Large number of landscape pages within a portrait doc--do I have to textbox by hand every landscape? mlkmnsgrl Word 7 01-05-2015 05:19 PM
Print 2 pages to a sheet in Landscape page orientation Alexie Excel 1 09-18-2010 01:29 AM
Multicolumn Multipage makaveli89 Word 0 11-10-2008 11:52 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:58 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft