Link to home
Start Free TrialLog in
Avatar of wiredemc12
wiredemc12

asked on

Print VBA Srting

Is it possible to print a string with vba? For example:
    Dim test As String
    test.PrintOut

Open in new window

Avatar of Norie
Norie

Print it where?
Avatar of wiredemc12

ASKER

I want to print text to the printer, but I do not want to store the text in any of the worksheets
You could write the text string to a cell, print it out using the Range.Printout method, then delete it:
Public Sub PrintText()

   Dim strText As String
   Dim rng As Excel.Range
   Dim sht As Excel.Worksheet
   
   strText = "Test string"
   Set sht = Application.Sheets(1)
   sht.Activate
   Set rng = sht.Range("A3")
   rng.Activate
   rng.Value = strText
   rng.PrintOut
   rng.Value = ""
   
End Sub

Open in new window

I dont want to put the text into the worksheet. Is this impossible?
ASKER CERTIFIED SOLUTION
Avatar of Helen Feddema
Helen Feddema
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial