Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Print VBA Srting

Posted on 2016-08-19
5
Medium Priority
?
78 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 35

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 2000 total points
ID: 41763061
I don't think so, but at least this method doesn't leave anything in the worksheet.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
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…

618 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