Solved

Print VBA Srting

Posted on 2016-08-19
5
39 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 AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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 lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

831 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