|
-
Jul 15th, 2004, 01:03 PM
#1
Thread Starter
Lively Member
Preview
Hi All:
I need help on how to code in vb to preview excel report. I tried the following line of code, but I get an error.
EXCELOBJ.ActiveWorkbook.PrintPreview
Thanks
-
Jul 16th, 2004, 04:36 AM
#2
Addicted Member
Your code as shown is correct. Try
EXCELOBJ.ActiveSheet.PrintPreview
If this doesn't work we will need to see more of your code.
If the sheet is blank it will not work.
Regards
BrianB
-------------------------------
-
Jul 16th, 2004, 09:12 AM
#3
Thread Starter
Lively Member
Print Preview
Hi BrianB:
The print Preview still does not work. Please find below my codes.
Dim EXCELOBJ As Excel.Application
Dim EXCELBOOK As Excel.Workbook ' Workbook object
Dim EXCELSHEET As Excel.Worksheet 'Worksheet object
SaveFile = ""
FileExtension = "*.xls"
SourcePath = "S:\"
FileName = Dir(SourcePath & FileExtension, vbNormal)
SaveFile = App.Path & "\Rpts\" & File
'Create Excel Object
Set EXCELOBJ = CreateObject("Excel.Application")
EXCELOBJ.Visible = False
EXCELOBJ.Workbooks.Open FileName:=App.Path & "\Rpts\" &
Set EXCELBOOK = EXCELOBJ.ActiveWorkbook
Set EXCELSHEET = EXCELBOOK.ActiveSheet
Set EXCELSHEET = EXCELOBJ.ActiveWorkbook.Sheets(1)
Set EXCELSHEET = EXCELBOOK.ActiveSheet
'I have a loop that populate and create my excel file here
'Print preview
EXCELOBJ.ActiveSheet.PrintPreview (when this line is executed, I get an error. The error is "This action cannot be completed because other application is busy.")
What do I need to do?
Thanks
-
Aug 2nd, 2004, 10:30 PM
#4
This works for me. You need to set the visible property
to true before you do a printpreview.
VB Code:
EXCELOBJ.Visible = True
EXCELOBJ.ActiveSheet.PrintPreview
HTH
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 3rd, 2004, 08:08 AM
#5
Thread Starter
Lively Member
Resolved: Print Preview
Thanks for your help!!!
-
Aug 3rd, 2004, 01:17 PM
#6
No prob.
Don't forget to edit you original post's subject with [Resolved]
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|