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

VBAMicrosoft ExcelVisual Basic.NETVisual Basic ClassicVB Script

Avatar of undefined
Last Comment
Helen Feddema

8/22/2022 - Mon
Norie

Print it where?
wiredemc12

ASKER
I want to print text to the printer, but I do not want to store the text in any of the worksheets
Helen Feddema

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

All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
wiredemc12

ASKER
I dont want to put the text into the worksheet. Is this impossible?
ASKER CERTIFIED SOLUTION
Helen Feddema

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.