Solved

Print VBA Srting

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

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

738 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