Solved

Print VBA Srting

Posted on 2016-08-19
5
34 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

948 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

19 Experts available now in Live!

Get 1:1 Help Now