Solved

Print VBA Srting

Posted on 2016-08-19
5
29 Views
Last Modified: 2016-08-19
Is it possible to print a string with vba? For example:
    Dim test As String
    test.PrintOut

Open in new window

0
Comment
Question by:wiredemc12
  • 2
  • 2
5 Comments
 
LVL 33

Expert Comment

by:Norie
ID: 41762528
Print it where?
0
 

Author Comment

by:wiredemc12
ID: 41762534
I want to print text to the printer, but I do not want to store the text in any of the worksheets
0
 
LVL 31

Expert Comment

by:Helen_Feddema
ID: 41762580
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
 

Author Comment

by:wiredemc12
ID: 41762834
I dont want to put the text into the worksheet. Is this impossible?
0
 
LVL 31

Accepted Solution

by:
Helen_Feddema earned 500 total points
ID: 41763061
I don't think so, but at least this method doesn't leave anything in the worksheet.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that undeā€¦
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now