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

Print Preview Excel Template with VB 2010

P: 14

I can't get this to work. My program fills all the values into an Excel spreadsheet- no problems there. What I'd like to do is a print preview/print function. I can't seem to get my code right, all I get are blank pages in the print preview box.

Expand|Select|Wrap|Line Numbers
  1.             Dim oExcel As Object = CreateObject("Excel.Application")
  2.             oExcel.Workbooks.Open("C:\DailyLogs\DailyLog.xlsx")
  3.             PrintPreviewDialog1.Document = PrintDocument1
  4.             PrintPreviewDialog1.ShowDialog()
  5.             oExcel.Sheet1.PrintPreview()
So as I see it, this should open excel, then navigate to the actual excel file. The print preview dialog should come up, which it does, and the excel sheet 1 should be previewing, but it's not? I don't have any errors, just a blank print preview.

Does anyone have any ideas? I've been up and down the internet with no luck.

Oct 1 '10 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 321
If you exit the code, leaving the sheet open, does print preview look right?

If you do a print preview while recording a macro, do you see anything done in code it generates that is helpful?
Oct 1 '10 #2

Post your reply

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