[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 81
  • Last Modified:

Print VBA Srting

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

Open in new window

0
wiredemc12
Asked:
wiredemc12
  • 2
  • 2
1 Solution
 
NorieCommented:
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
 
Helen FeddemaCommented:
I don't think so, but at least this method doesn't leave anything in the worksheet.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now