By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,994 Members | 2,073 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,994 IT Pros & Developers. It's quick & easy.

Are there formatting commands for the Print #, command

P: 4
I am using an excel sheet to keep track of the finances of my afterschool program. Each week I am creating an invoice for the families that have a different balance, outputing from the excel file to a new word file. Everything works except I was wondering if it is possible to format the output within or before the Print # statement. Just typically word formatting things like size, font, underline and what not. If not, is there an alternative solution that I could use?

I am not entirely new to programming, but am new to VB. I have found answers to all of my other syntax type issues on the web or through the VB help, but had no luck with this problem.

'Find the number of C sessions attended
a = Sheets(Week_of).Range("P" & x).Value
'Print C Session # and associated cost
Print #1, a; " Session C (PM) @ $6.00"; Tab(40); "$"; a * 6

I would like to change the font size of the whole print statement as well as underline the a and a * 6 value.

Thanks for your help,
Jan 10 '08 #1
Share this Question
Share on Google+
3 Replies

Expert 100+
P: 1,445

Are you Saving the values to a TextFile and then printing from there or directly Printing to the Printer...?

If using Second option, the "Printer" class has got all the Font Options..

Expand|Select|Wrap|Line Numbers
  1. Printer.FontName = "Courier New"
  2. Printer.FontBold = True
  3. Printer.Print "My First Doc"
  4. Printer.FontBold = False
  5. Printer.FontUnderline = True    
  6. Printer.Print "Second Line"
  7. Printer.NewPage
  8. Printer.EndDoc
Jan 10 '08 #2

P: 4
I am currently writing to a text file (I want a copy saved for future reference) then printing that file. I also currently don't have a printer where I do most of my coding, so I need a file to test the formatting that will be created.
Jan 10 '08 #3

Expert 5K+
P: 8,434
A couple of options come to mind.For instance...
  • Your VB code can drive Word directly, so in theory you could produce as fancy a report as you want.
  • VB includes other ways to produce a "data report", which I don't have any experience with.
  • This would be my preferred method. Add the Microsoft Rich TextBox Control to your project. Then you can throw your text into the RTB, select parts, format them how you want, then just save to an RTF file. Word will interpret RTF format, so it will come out the way you formatted it when loaded into Word. Make sure you save the file with extension ".RTF".
Jan 11 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.