Print VBA Srting

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

Open in new window

wiredemc12Asked:
Who is Participating?
 
Helen FeddemaConnect With a Mentor Commented:
I don't think so, but at least this method doesn't leave anything in the worksheet.
0
 
NorieVBA ExpertCommented:
Print it where?
0
 
wiredemc12Author Commented:
I want to print text to the printer, but I do not want to store the text in any of the worksheets
0
 
Helen FeddemaCommented:
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

0
 
wiredemc12Author Commented:
I dont want to put the text into the worksheet. Is this impossible?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.