[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2199
  • Last Modified:

Word VBA's "wdDialogFilePrint.show" command sends to printer with no dialog

Has anyone seen this?  Whether I run as part of a macro or launch from the Immediate window, in some cases (can't figure out why), using Dialogs(wdDialogFilePrint).Show doesn't show the Print dialog at all, but sends the document to print automatically to currently selected printer with default options.
0
NGloFile
Asked:
NGloFile
1 Solution
 
Joseph O'LoughlinCommented:
Hi NGloFile,
Is it a HP printer?  I have found their printer drivers buggy.  Try using a Microsoft driver for a similar model as your default (going to the same port)
usual disclaimers apply.  I'm away next week so don't expect a quick reply.
0
 
NGloFileAuthor Commented:
Thanks Atheist (like your handle!).

It's actually a Xerox printer, but I'd be surprised if it's a driver issue, since it's not affecting the result as much as behavior within the application (i.e., no dialog).  It seems to be redirecting the event of dialog.show to document.printout or something like that.
0
 
Joseph O'LoughlinCommented:
Can we review the vba?
0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
NGloFileAuthor Commented:
Sure.  But I should clarify two things:

1) This only happens sporadically, to certain users.  For others, it behaves as expected.
2) When it happens, you can re-create it just by going to the immediate window, typing "Dialogs(wdDialogFilePrint).Show and pressing Enter

The code:

Sub PrintToBond()

Dim myTray As String
Dim FirstPage As String
Dim OtherPage As String

' Get Current tray pages
FirstPage = ActiveDocument.Sections(1).PageSetup.FirstPageTray
OtherPage = ActiveDocument.Sections(1).PageSetup.OtherPagesTray

myTray = System.PrivateProfileString("", "HKEY_CURRENT_USER\software\whscripts", "Bond_Tray")

If myTray = "" Then

    myTray = "257"
   
End If

Dim sec As Section

For Each sec In ActiveDocument.Sections


    sec.PageSetup.FirstPageTray = myTray
    sec.PageSetup.OtherPagesTray = myTray
   
Next

System.PrivateProfileString("", "HKEY_CURRENT_USER\software\whscripts", "Bond_Tray") = myTray

Dialogs(wdDialogFilePrint).Show

' now set trays back
For Each sec In ActiveDocument.Sections


    sec.PageSetup.FirstPageTray = FirstPage
    sec.PageSetup.OtherPagesTray = OtherPage
   
Next


End Sub

Thanks.
0
 
Joseph O'LoughlinCommented:
See http:Q_20559573.html
or add
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
before
Dialogs(wdDialogFilePrint).Show
0
 
NGloFileAuthor Commented:
Thanks again.

Unfortunately, this didn't make a difference.  It doesn't seem to have any problem printing or printing the correct document.  Instead, it is just misinterpreting the command to show the dialog and going directly to print (almost like it's confusing the "File > Print ..." command with "File > Print" (no dialog options).

Thanks for trying, though.

NGloFile
0
 
NGloFileAuthor Commented:
It turns out that this issue was being caused by a third-party application we have installed that hijacks the _DocumentBeforePrint command.  We are working with the vendor on fixing this.

Thanks.
0
 
Joseph O'LoughlinCommented:
Intresting...
0
 
NGloFileAuthor Commented:
I went through the procedure identified above for closing a question because I answered it myself(and requesting a refund) back in December (by contacting the moderator).  We discovered the problem was caused by a third-party add-in we are using in Word.  Let me know if I need to do anything else.  Thanks.
0
 
moduloCommented:
PAQed with points refunded (125)

modulo
Community Support Moderator
0
 
RobertaGelbCommented:
THANK YOU!!! Just a note:  We had this experience with Word2007 and Interwoven FileSite 8.2.

 We deleted the line
                  Dialogs(wdDialogFilePrint).Show
and used Interwoven's  
                 AutoMacro.FilePrintBinding
 in its place

Requires that you set references (in Tools References) to IMan02K.dot
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now