Click here to Skip to main content
15,867,834 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have an Excel form with a button so the user can print out the form after filling in to provide the required hardcopy for signature.
Posted
Comments
Zoltán Zörgő 19-Jan-15 15:59pm    
Good for you. And what is the question - as in Excel you have VBA, not VBS? And what vahe you tired?

1 solution

Let us omit the fact, hat you are speaking about Excel VBA, and not VBS. Have you tried to google just a little bit? If yes, what is the problem with this: Sheets.PrintOut Method[^]?
 
Share this answer
 
Comments
Member 11386527 19-Jan-15 18:43pm    
Thanks for your response. Yes, Excel VBA. (Showing my inexperience) I tried the following code but since my form pops up when clicking a button on the sheet, theis code prints the sheet rather than my form.

Private Sub CommandPrint_Click()
ActiveSheet.PrintOut
End Sub

Here is other code I found someone used but didn't know how to designate my printer. I tried changing the word printer to an IP address or LPT1 but it wouldn't complie.

Private Sub CommandPrint_Click()
' Capture the entire form including title and border.
Set Picture1.Picture = CheckRequestForm(Me)

' Print the current contents of the picture box.
PrintPictureToFitPage Printer, Picture1.Picture
Printer.EndDoc

' Clear out the picture box.
Set Picture1.Picture = Nothing
End Sub
Zoltán Zörgő 20-Jan-15 2:55am    
If you have a method, like this, to have a screenshot of the UserForm, with little modification, you can paste this image to a sheet, and print the sheet as you like.
Member 11386527 20-Jan-15 8:50am    
Great suggestion. I will investigate that. Thanks!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900