disable print preview from xlDialogPrint
disable print preview from xlDialogPrint
disable print preview from xlDialogPrint
disable print preview from xlDialogPrint
disable print preview from xlDialogPrint
disable print preview from xlDialogPrint disable print preview from xlDialogPrint disable print preview from xlDialogPrint disable print preview from xlDialogPrint disable print preview from xlDialogPrint disable print preview from xlDialogPrint disable print preview from xlDialogPrint disable print preview from xlDialogPrint
disable print preview from xlDialogPrint disable print preview from xlDialogPrint
disable print preview from xlDialogPrint
Go Back  Xtreme Visual Basic Talk > > > > disable print preview from xlDialogPrint


Reply
 
Thread Tools Display Modes
  #1  
Old 12-10-2003, 05:29 AM
w_seyller w_seyller is offline
Regular
 
Join Date: Nov 2003
Posts: 75
Default disable print preview from xlDialogPrint


Is there anyway I can disable print preview from the xlDialogPrint. I do not need it for any reason, and if the user clicks on print preview it will cause some problems.
Reply With Quote
  #2  
Old 12-10-2003, 09:05 AM
italkid's Avatar
italkid italkid is offline
Down...

Retired Moderator
* Expert *
 
Join Date: Dec 2002
Location: Belgium.
Posts: 6,731
Default

There is a way to disable all of the printpreview buttons in all of Excel's
toolbars and manu's but i'm not sure about the "Print" dialog.
And i can't test that one since no printer installed.
But why does it causes problems if i may ask ?
Reply With Quote
  #3  
Old 12-10-2003, 03:04 PM
w_seyller w_seyller is offline
Regular
 
Join Date: Nov 2003
Posts: 75
Default

I have list of part numbers for HP Laser Cartridges and an option button to select "OEM" Or "Compatible". Then i have a cmdbutton to print out a starter form for a testing procedure. Some time I get an error:run-time error '1004' Show method of dialog class failed. And it points to the xlDialogPrint line of code. If I click print to bring up the dialog and then cancel then bring it up again sometimes I get this error and then I have to manually end task the spreadsheet that is in memory. Sometimes it does it. Sometimes it don't. And also I think it's fully related to the preview, although it seems to have sometimes when closing it. I can see no pattern, it does it random. Any suggestion.


also i'm using vb6

Code:
Public Sub Starter2(frmStarterform As Form) 'Open Starter2 Change Cells According to cboStarterform then print Dim objExcel As Excel.Application Dim xlWB As Excel.Workbook Set objExcel = New Excel.Application Set xlWB = objExcel.Workbooks.Open(App.Path & "\Starter2.XLS") With xlWB.Worksheets("Sheet1").Range("A30") .Value = A30 If FormatA30 = 3 Then .Characters(7, 3).Font.Bold = True ElseIf FormatA30 = 4 Then .Characters(7, 4).Font.Bold = True End If End With If Startertype = 1 Then xlWB.Worksheets("Sheet1").PageSetup.LeftHeader = "&B &12" & CartheaderC Else With xlWB.Worksheets("Sheet1") .PageSetup.LeftHeader = "&B &12" & CartheaderO .Range("B3:B8").Value = "OEM" End With End If objExcel.Dialogs(xlDialogPrint).Show 'opens print dialog box xlWB.Worksheets("Sheet1").Visible = xlSheetVeryHidden CleanUp: Call xlWB.Close(SaveChanges:=False) objExcel.Quit Set objExcel = Nothing End Sub
Reply With Quote
  #4  
Old 12-10-2003, 03:10 PM
w_seyller w_seyller is offline
Regular
 
Join Date: Nov 2003
Posts: 75
Default

Here is the sub that calls 4 subprocedures, one of which is above in the previous post.



Code:
Private Sub cmdPrintstarter_Click() Chargetype = "none" Select Case cboStarterform 'Set Left Header for Starter Forms Case Is = "HP 92291A NX" CartheaderC = "HP 92291A Compatible ASTM Starter Form (10,250 Page Yield)" CartheaderO = "HP 92291A OEM ASTM Starter Form (10,250 Page Yield)" FormatA30 = 4 FormatA52 = 4 FormatA74 = 4 A30 = "Print 2500 5% Pages" A52 = "Print 1500 5% Pages" A74 = "Print 1500 5% Pages" Call Starter4(frmStarterform) Case Is = "HP 92291X NX HY" CartheaderC = "HP 92291X Compatible ASTM Starter Form (13,500 Page Yield)" CartheaderO = "HP 92291X OEM ASTM Starter Form (13,500 Page Yield)" FormatA30 = 4 FormatA52 = 4 FormatA74 = 4 A30 = "Print 3500 5% Pages" A52 = "Print 2250 5% Pages" A74 = "Print 2250 5% Pages" Call Starter4(frmStarterform) Case Is = "HP 92274A PX" CartheaderC = "HP 92274A Compatible ASTM Starter Form (3,350 Page Yield)" CartheaderO = "HP 92274A OEM ASTM Starter Form (3,350 Page Yield)" FormatA30 = 3 FormatA52 = 3 A30 = "Print 750 5% Pages" A52 = "Print 250 5% Pages" Call Starter3(frmStarterform) Case Is = "HP 92295A SX" CartheaderC = "HP 92295A Compatible ASTM Starter Form (4,000 Page Yield)" CartheaderO = "HP 92295A OEM ASTM Starter Form (4,000 Page Yield)" FormatA30 = 4 FormatA52 = 3 A30 = "Print 1250 5% Pages" A52 = "Print 250 5% Pages" Chargetype = "C5. Primary Corona Used" Call Starter3(frmStarterform) Case Is = "HP C3903A VX" CartheaderC = "HP C3903A Compatible ASTM Starter Form (4,000 Page Yield)" CartheaderO = "HP C3903A OEM ASTM Starter Form (4,000 Page Yield)" FormatA30 = 4 FormatA52 = 3 A30 = "Print 1250 5% Pages" A52 = "Print 250 5% Pages" Call Starter3(frmStarterform) Case Is = "HP C3909A WX" CartheaderC = "HP C3909A Compatible ASTM Starter Form (15,000 Page Yield)" CartheaderO = "HP C3909A OEM ASTM Starter Form (15,000 Page Yield)" FormatA30 = 4 FormatA52 = 4 FormatA74 = 4 A30 = "Print 3750 5% Pages" A52 = "Print 2750 5% Pages" A74 = "Print 2750 5% Pages" Call Starter4(frmStarterform) Case Is = "HP C3909X WX HY" CartheaderC = "HP C3909X Compatible ASTM Starter Form (17,100 Page Yield)" CartheaderO = "HP C3909X OEM ASTM Starter Form (17,100 Page Yield)" FormatA30 = 4 FormatA52 = 4 FormatA74 = 4 A30 = "Print 4250 5% Pages" A52 = "Print 3250 5% Pages" A74 = "Print 3250 5% Pages" Call Starter4(frmStarterform) Case Is = "HP Q2612A HP1012" CartheaderC = "HP Q2612A Compatible ASTM Starter Form (2,000 Page Yield)" CartheaderO = "HP Q2612A OEM ASTM Starter Form (2,000 Page Yield)" Call Starter1(frmStarterform) Case Is = "HP C4092A HP1100" CartheaderC = "HP C4092A Compatible ASTM Starter Form (2,500 Page Yield)" CartheaderO = "HP C4092A OEM ASTM Starter Form (2,500 Page Yield)" FormatA30 = 3 A30 = "Print 500 5% Pages" Call Starter2(frmStarterform) Case Is = "HP Q2624A HP1150" CartheaderC = "HP Q2624A Compatible ASTM Starter Form (2,500 Page Yield)" CartheaderO = "HP Q2624A OEM ASTM Starter Form (2,500 Page Yield)" FormatA30 = 3 A30 = "Print 500 5% Pages" Call Starter2(frmStarterform) Case Is = "HP Q2624X HP1150 HY" CartheaderC = "HP Q2624X Compatible ASTM Starter Form (4,000 Page Yield)" CartheaderO = "HP Q2624X OEM ASTM Starter Form (4,000 Page Yield)" FormatA30 = 4 FormatA52 = 3 A30 = "Print 1250 5% Pages" A52 = "Print 250 5% Pages" Call Starter3(frmStarterform) Case Is = "HP C7115A HP1200" CartheaderC = "HP C7115A Compatible ASTM Starter Form (2,500 Page Yield)" CartheaderO = "HP C7115A OEM ASTM Starter Form (2,500 Page Yield)" FormatA30 = 3 A30 = "Print 500 5% Pages" Call Starter2(frmStarterform) Case Is = "HP C7115X HP1200 HY" CartheaderC = "HP C7115X Compatible ASTM Starter Form (4,000 Page Yield)" CartheaderO = "HP C7115X OEM ASTM Starter Form (4,000 Page Yield)" FormatA30 = 4 FormatA52 = 3 A30 = "Print 1250 5% Pages" A52 = "Print 250 5% Pages" Call Starter3(frmStarterform) Case Is = "HP Q2613A HP1300" CartheaderC = "HP Q2613A Compatible ASTM Starter Form (2,500 Page Yield)" CartheaderO = "HP Q2613A OEM ASTM Starter Form (2,500 Page Yield)" FormatA30 = 3 A30 = "Print 500 5% Pages" Call Starter2(frmStarterform) Case Is = "HP Q2613X HP1300 HY" CartheaderC = "HP Q2613X Compatible ASTM Starter Form (4,000 Page Yield)" CartheaderO = "HP Q2613X OEM ASTM Starter Form (4,000 Page Yield)" FormatA30 = 4 FormatA52 = 3 A30 = "Print 1250 5% Pages" A52 = "Print 250 5% Pages" Call Starter3(frmStarterform) Case Is = "HP C4096A HP2100" CartheaderC = "HP C4096A Compatible ASTM Starter Form (5,000 Page Yield)" CartheaderO = "HP C4096A OEM ASTM Starter Form (5,000 Page Yield)" FormatA30 = 4 FormatA52 = 3 A30 = "Print 1500 5% Pages" A52 = "Print 750 5% Pages" Call Starter3(frmStarterform) Case Is = "HP Q2610A HP2300" CartheaderC = "HP Q2610A Compatible ASTM Starter Form (6,000 Page Yield)" CartheaderO = "HP Q2610A OEM ASTM Starter Form (6,000 Page Yield)" FormatA30 = 4 FormatA52 = 4 A30 = "Print 2000 5% Pages" A52 = "Print 1000 5% Pages" Call Starter3(frmStarterform) Case Is = "HP C4127A HP4000" CartheaderC = "HP C4127A Compatible ASTM Starter Form (6,000 Page Yield)" CartheaderO = "HP C4127A OEM ASTM Starter Form (6,000 Page Yield)" FormatA30 = 4 FormatA52 = 4 A30 = "Print 2000 5% Pages" A52 = "Print 1000 5% Pages" Call Starter3(frmStarterform) Case Is = "HP C4127X HP4000 HY" CartheaderC = "HP C4127X Compatible ASTM Starter Form (10,000 Page Yield)" CartheaderO = "HP C4127X OEM ASTM Starter Form (10,000 Page Yield)" FormatA30 = 4 FormatA52 = 4 FormatA74 = 4 A30 = "Print 2500 5% Pages" A52 = "Print 1500 5% Pages" A74 = "Print 1500 5% Pages" Call Starter4(frmStarterform) Case Is = "HP C8061A HP4100" CartheaderC = "HP C8061A Compatible ASTM Starter Form (6,000 Page Yield)" CartheaderO = "HP C8061A OEM ASTM Starter Form (6,000 Page Yield)" FormatA30 = 4 FormatA52 = 4 A30 = "Print 2000 5% Pages" A52 = "Print 1000 5% Pages" Call Starter3(frmStarterform) Case Is = "HP C8061X HP4100 HY" CartheaderC = "HP C8061X Compatible ASTM Starter Form (10,000 Page Yield)" CartheaderO = "HP C8061X OEM ASTM Starter Form (10,000 Page Yield)" FormatA30 = 4 FormatA52 = 4 FormatA74 = 4 A30 = "Print 2500 5% Pages" A52 = "Print 1500 5% Pages" A74 = "Print 1500 5% Pages" Call Starter4(frmStarterform) Case Is = "HP Q1338A HP4200" CartheaderC = "HP Q1338A Compatible ASTM Starter Form (12,000 Page Yield)" CartheaderO = "HP Q1338A OEM ASTM Starter Form (12,000 Page Yield)" FormatA30 = 4 FormatA52 = 4 FormatA74 = 4 A30 = "Print 3000 5% Pages" A52 = "Print 2000 5% Pages" A74 = "Print 2000 5% Pages" Call Starter4(frmStarterform) Case Is = "HP Q1339A HP4300" CartheaderC = "HP Q1339A Compatible ASTM Starter Form (18,000 Page Yield)" CartheaderO = "HP Q2339A OEM ASTM Starter Form (18,000 Page Yield)" FormatA30 = 4 FormatA52 = 4 FormatA74 = 4 A30 = "Print 4500 5% Pages" A52 = "Print 3500 5% Pages" A74 = "Print 3500 5% Pages" Call Starter4(frmStarterform) Case Is = "HP C4129X HP5000" CartheaderC = "HP C4129X Compatible ASTM Starter Form (10,000 Page Yield)" CartheaderO = "HP C4129X OEM ASTM Starter Form (10,000 Page Yield)" FormatA30 = 4 FormatA52 = 4 FormatA74 = 4 A30 = "Print 2500 5% Pages" A52 = "Print 1500 5% Pages" A74 = "Print 1500 5% Pages" Call Starter4(frmStarterform) Case Is = "HP C4182X HP8100" CartheaderC = "HP C3906A Compatible ASTM Starter Form (20,000 Page Yield)" CartheaderO = "HP C3906A OEM ASTM Starter Form (20,000 Page Yield)" FormatA30 = 4 FormatA52 = 4 FormatA74 = 4 A30 = "Print 5000 5% Pages" A52 = "Print 4000 5% Pages" A74 = "Print 4000 5% Pages" Call Starter4(frmStarterform) Case Is = "HP C8543X HP9000" CartheaderC = "HP C8543X Compatible ASTM Starter Form (30,000 Page Yield)" CartheaderO = "HP C8543X OEM ASTM Starter Form (30,000 Page Yield)" FormatA30 = 4 FormatA52 = 4 FormatA74 = 4 A30 = "Print 7500 5% Pages" A52 = "Print 6500 5% Pages" A74 = "Print 6500 5% Pages" Call Starter4(frmStarterform) End Select End Sub
Reply With Quote
  #5  
Old 12-11-2003, 02:11 AM
tinyjack's Avatar
tinyjackdisable print preview from xlDialogPrint tinyjack is offline
Captain TJ

Forum Leader
* Expert *
 
Join Date: Jun 2003
Location: England
Posts: 1,664
Default

I am not sure that print preview is going to be your problem. Could we see the code for the other Starter subs.

TJ
__________________
Oh dear, I need a beer.
Online Motorsport Game
Reply With Quote
  #6  
Old 12-11-2003, 05:53 AM
w_seyller w_seyller is offline
Regular
 
Join Date: Nov 2003
Posts: 75
Default

Yeah, I made a typo in the last thread. I meant that I think it's not fully related to print preview, actually I don't think it is at all. But here are the other subs. Also please keep in mind that I am not a professional programmer, I could easily make a mistake or do something wrong anywhere in my project. If it comes down to it I could send my source code if someone would like to help me solve this, if someone would give me a suggestion on how to upload it.

Code:
Public Sub Starter3(frmStarterform As Form) 'Open Starter3 Change Cells According to cboStarterform then print Dim objExcel As Excel.Application Dim xlWB As Excel.Workbook Set objExcel = New Excel.Application Set xlWB = objExcel.Workbooks.Open(App.Path & "\Starter3.XLS") If Chargetype = "C5. Primary Corona Used" Then With xlWB.Worksheets("Sheet1").Range("A6") .Value = "C5. Primary Corona Used" .Characters(1, 3).Font.Bold = True .Characters(1, 3).Font.Size = 12 End With Else With xlWB.Worksheets("Sheet1").Range("A6") .Value = "C5. PCR Used" .Characters(1, 3).Font.Bold = True .Characters(1, 3).Font.Size = 12 End With End If With xlWB.Worksheets("Sheet1").Range("A30") .Value = A30 If FormatA30 = 3 Then .Characters(7, 3).Font.Bold = True ElseIf FormatA30 = 4 Then .Characters(7, 4).Font.Bold = True End If End With With xlWB.Worksheets("Sheet1").Range("A52") .Value = A52 If FormatA52 = 3 Then .Characters(7, 3).Font.Bold = True ElseIf FormatA52 = 4 Then .Characters(7, 4).Font.Bold = True End If End With If Startertype = 1 Then xlWB.Worksheets("Sheet1").PageSetup.LeftHeader = "&B &12" & CartheaderC Else With xlWB.Worksheets("Sheet1") .PageSetup.LeftHeader = "&B &12" & CartheaderO .Range("B3:B8").Value = "OEM" End With End If Application.Dialogs(xlDialogPrint).Show 'opens print dialog box xlWB.Worksheets("Sheet1").Visible = xlSheetVeryHidden CleanUp: Call xlWB.Close(SaveChanges:=False) objExcel.Quit Set objExcel = Nothing End Sub Public Sub Starter4(frmStarterform As Form) 'Open Starter4 Change Cells According to cboStarterform then print Dim objExcel As Excel.Application Dim xlWB As Excel.Workbook Set objExcel = New Excel.Application Set xlWB = objExcel.Workbooks.Open(App.Path & "\Starter4.XLS") With xlWB.Worksheets("Sheet1").Range("A30") .Value = A30 .Characters(7, 4).Font.Bold = True End With With xlWB.Worksheets("Sheet1").Range("A52") .Value = A52 .Characters(7, 4).Font.Bold = True End With With xlWB.Worksheets("Sheet1").Range("A74") .Value = A74 .Characters(7, 4).Font.Bold = True End With If Startertype = 1 Then xlWB.Worksheets("Sheet1").PageSetup.LeftHeader = "&B &12" & CartheaderC Else With xlWB.Worksheets("Sheet1") .PageSetup.LeftHeader = "&B &12" & CartheaderO .Range("B3:B8").Value = "OEM" End With End If Application.Dialogs(xlDialogPrint).Show 'opens print dialog box xlWB.Worksheets("Sheet1").Visible = xlSheetVeryHidden CleanUp: Call xlWB.Close(SaveChanges:=False) objExcel.Quit Set objExcel = Nothing End Sub Public Sub Starter1(frmStarterform As Form) Dim objExcel As Excel.Application Dim xlWB As Excel.Workbook Set objExcel = New Excel.Application Set xlWB = objExcel.Workbooks.Open(App.Path & "\Starter1.XLS") If Startertype = 1 Then xlWB.Worksheets("Sheet1").PageSetup.LeftHeader = "&B &12" & CartheaderC Else With xlWB.Worksheets("Sheet1") .PageSetup.LeftHeader = "&B &12" & CartheaderO .Range("B3:B8").Value = "OEM" End With End If objExcel.Dialogs(xlDialogPrint).Show 'opens print dialog box xlWB.Worksheets("Sheet1").Visible = xlSheetVeryHidden CleanUp: Call xlWB.Close(SaveChanges:=False) objExcel.Quit Set objExcel = Nothing End Sub

These are located in a module.
Reply With Quote
  #7  
Old 12-11-2003, 05:59 AM
tinyjack's Avatar
tinyjackdisable print preview from xlDialogPrint tinyjack is offline
Captain TJ

Forum Leader
* Expert *
 
Join Date: Jun 2003
Location: England
Posts: 1,664
Default

In Starter3 and Starter4 you are calling the dialog differently than in Starter1 and 2, which was my guess as to your problem. Does the problem only occur when you select something that uses version 3&4?

TJ
__________________
Oh dear, I need a beer.
Online Motorsport Game
Reply With Quote
  #8  
Old 12-11-2003, 06:06 AM
w_seyller w_seyller is offline
Regular
 
Join Date: Nov 2003
Posts: 75
Default

That was it. I should have caught that. Thanks

Code:
Application.Dialogs(xlDialogPrint).Show 'opens print dialog box 'this is the old code i used to use objExcel.Dialogs(xlDialogPrint).Show 'opens print dialog box 'this is the new way i do it because it works better
Reply With Quote
  #9  
Old 12-11-2003, 09:19 AM
Mike Rosenblum's Avatar
Mike Rosenblum Mike Rosenblum is offline
Microsoft Excel MVP

Forum Leader
* Guru *
 
Join Date: Jul 2003
Location: New York, NY, USA
Posts: 7,848
Default

w_seyller:

When Automating the Excel.Application from VB 6.0, you cannot ever use Application.<whatever> you must ALWAYS use objExcel.<whatever> instead.

This is why the 1st Line is no good in your post above.

-- Mike
__________________
My Articles:
| Excel from .NET | Excel RibbonX using VBA | Excel from VB6 | CVErr in .NET | MVP |
Avatar by Lebb
Reply With Quote
  #10  
Old 12-11-2003, 11:20 AM
w_seyller w_seyller is offline
Regular
 
Join Date: Nov 2003
Posts: 75
Default

thanks for clearing that up for me. I was told this before, but i overlooked the fact that I forgot to make changes to everthing. application was what i was using before I knew.

Thanks guys, you helped me out.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
print function girmander General 4 11-21-2003 07:06 AM
Webbrowser object hide with print preview ptrapp Interface and Graphics 7 12-11-2002 03:01 PM
why does my code no longer work dapul General 4 11-07-2002 06:22 PM
Print Preview KidCoder General 13 07-24-2002 07:20 AM
How to set Excel Print Preview Margins MarkNewVBGuy Word, PowerPoint, Outlook, and Other Office Products 1 12-14-2001 12:57 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
disable print preview from xlDialogPrint
disable print preview from xlDialogPrint
disable print preview from xlDialogPrint disable print preview from xlDialogPrint
disable print preview from xlDialogPrint
disable print preview from xlDialogPrint
disable print preview from xlDialogPrint disable print preview from xlDialogPrint disable print preview from xlDialogPrint disable print preview from xlDialogPrint disable print preview from xlDialogPrint disable print preview from xlDialogPrint disable print preview from xlDialogPrint
disable print preview from xlDialogPrint
disable print preview from xlDialogPrint
 
disable print preview from xlDialogPrint
disable print preview from xlDialogPrint
 
-->