VBA Printing

Posted on 2003-03-31
Medium Priority
Last Modified: 2010-05-03
Hi Everyone, I am having problems printing in VBA. Here is my code

MsgBox "Information on purchase " & vbCrLf & vbCrLf & "Total cost:" & vbCrLf & vbCrLf & " £" & Cells(29, 3) & vbCrLf & vbCrLf & "Duration:" & vbCrLf & vbCrLf & Cells(7, 8) & vbCrLf & vbCrLf & "Car:" & vbCrLf & vbCrLf & Cells(5, 8)
Printer.Print "Receipt of Rent"
Printer.Print ""

However nothing prints, i get a "object required" error. The print code seems to work in VB, but not VBA. Can anyone help?

Any help is appreciated.

Question by:Helix
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Expert Comment

ID: 8237366
some VB objects are not available in VBA, like the printer and screen object.
you'll have to accomplish that different way.
(e.g. put it on a excel sheet/wordt doc and print that.)

Author Comment

ID: 8237635
Hi all, i still yet have to get printing working in VBA, here is my code so far. I have made a user form for the receipt:

MsgBox "Information on purchase " & vbCrLf & vbCrLf & "Total cost:" & vbCrLf & vbCrLf & " £" & Cells(29, 3) & vbCrLf & vbCrLf & "Duration:" & vbCrLf & vbCrLf & Cells(7, 8) & vbCrLf & vbCrLf & "Car:" & vbCrLf & vbCrLf & Cells(5, 8)
UserForm1.lblcar.Caption = Cells(5, 8)
UserForm1.lblDuration.Caption = Cells(7, 8)
UserForm1.lblTotalcost.Caption = "£ " & Cells(29, 3)

When the userform is shown, the correct values are shown, however when it's printed, nothing is in the labels. They have no caption by default.

Accepted Solution

AKbor75 earned 75 total points
ID: 8241449
as you have all data on a sheet, why don't you format that sheet and print it. works great as you have many formatting options.

Expert Comment

ID: 8531281
Hi Helix,
This old question (QID 20568496) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question