Word XP / Office XP & Print to File Dialogue

JackDeAlan627
JackDeAlan627 used Ask the Experts™
on
I have a custom Macro that produces a PS and TXT file. We are using the print to file function to send this out to a drive. In Word 97/Windows 95 Environment, there was no problem using the Linotronic 300 v47.1 driver with this Macro.

As the organization upgrades to Windows XP and the Office XP environment, we are testing our Macros for this environment. We are unable to avoid the Print to File dialogue. It always asks to save as a PRN file having the linotronic printer set as the default FILE: Create print to file as the driver.

Is there a way on the OS to bypass this save screen and instead of getting the PRN file, to automatically save to PS without requiring the user to intervene. Thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2006

Commented:
could you post some relevant code to look at? since it worked in 97 probably is a minor change in the settings to text file

Author

Commented:
Sub SaveAs_Ps()
On Error GoTo Errorhandler
vQuote = """"
vInitialPrinter = ActivePrinter()

vPSFileName = ActiveDocument.Name
vPSFileName = Left(vPSFileName, Len(vPSFileName) - 3)
vPSFileName = "c:\internetdrive\" & vPSFileName & "ps"
vPSFileName = vQuote & vPSFileName & vQuote
  SendKeys vPSFileName & "{Enter}"
   
   
   ActivePrinter = "Linotronic 300 v47.1"

'IT BAILS RIGHT HERE - PRINT TO FILE SCREEN COMES UP ON THIS LINE OF CODE.
   Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
   wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
   Collate:=True, Background:=False, PrintToFile:=True

'UPON THIS COMMAND BEING EXECUTED, THE ERROR COMES UP AND REQUST A FILENAME BE ENTERED WITH THE PRN FILE BEING THE DEFAULT TO ENTER


ActivePrinter = vInitialPrinter
vPSFileName = Left(vPSFileName, Len(vPSFileName) - 1)
vPSFileName = Right(vPSFileName, Len(vPSFileName) - 1)
Exit Sub

Errorhandler:
  If (Err.Number = 5) Then
  Err.Clear
   MsgBox "No Postscrip File Created", , "Error PostScript File"
 End If
  End Sub

'-----------------------------------------------------------------------
Sub SaveAs_Txt() '

Response=
If Response = vbYes Then
vFilename = ActiveDocument.Name
vFilename = Left(vFilename, Len(vFilename) - 3)
vFilename = vFilename & "txt"
ChangeFileOpenDirectory "c:\internetfiles"

  ActiveDocument.SaveAs FileName:=vFilename, FileFormat:=wdFormatDOSText, _
    LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
    :="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
    SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
    False
Else
    Exit Sub
End If
SaveAs_Ps
SaveAs_Doc
End Sub
Top Expert 2006

Commented:
why did you accept my comment as answer? you can leave it open for as long as your happy, and other are more interested while it's open ....
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

Author

Commented:
oops sorry how do i open this up again...help me. i am new to the community.
Top Expert 2006

Commented:
we got that corrected, first read the FAQ >>> http://www.experts-exchange.com/help/qnaFAQ.jsp :) then i'll try to look at that code
Top Expert 2006

Commented:
what i see here

'IT BAILS RIGHT HERE - PRINT TO FILE SCREEN COMES UP ON THIS LINE OF CODE.
   Application.PrintOut FileName:="", _
                        Range:=wdPrintAllDocument, _
                        Item:=wdPrintDocumentContent, _
                        Copies:=1, _
                        Pages:="", _
                        PageType:=wdPrintAllPages, _
                        Collate:=True, _
                        Background:=False, _
                        PrintToFile:=True

'UPON THIS COMMAND BEING EXECUTED, THE ERROR COMES UP AND REQUST A FILENAME BE ENTERED WITH THE PRN FILE BEING THE DEFAULT TO ENTER

is you leave the filename open so it's logical to come up and asking for one

   Application.PrintOut FileName:="", _ < -------- is empty
Top Expert 2006
Commented:
you rather would do something like

Application.PrintOut FileName:=vPSFileName, _

and leave the sendkeys out of it or am i missing something more in your code

Author

Commented:
Its working well with acknowledging the fact its not requiring a printer files screen but the file is not printing in PS unfortunately. Any ideas?
Top Expert 2006

Commented:
i see you asked a second question and tried to reproduce your situation

OS and Office are 2003 betas so there micgt be a difference

anyway created a new printer to file the Lino as per above then tried this code, it errored on the printout with an error refering to hte fact that couldn't open the text convertor tool

Sub SaveAs_Ps()
Dim vQuote  As String
Dim vPSFileName As String
Dim vInitialPrinter
Dim ActivePrinter

On Error GoTo Errorhandler

  vQuote = """"
  vInitialPrinter = Application.ActivePrinter()
  vPSFileName = ActiveDocument.Name
  'vPSFileName = Left(vPSFileName, Len(vPSFileName) - 3)
  vPSFileName = "c:\temp\" & vPSFileName & ".ps"
  vPSFileName = vQuote & vPSFileName & vQuote
 
  Application.ActivePrinter = "Linotronic 300 v47.1"

  Application.PrintOut FileName:=vPSFileName, _
                        Range:=wdPrintAllDocument, _
                        Item:=wdPrintDocumentContent, _
                        Copies:=1, _
                        Pages:="", _
                        PageType:=wdPrintAllPages, _
                        Collate:=True, _
                        Background:=False, _
                        PrintToFile:=True

  ActivePrinter = vInitialPrinter
  vPSFileName = Left(vPSFileName, Len(vPSFileName) - 1)
  vPSFileName = Right(vPSFileName, Len(vPSFileName) - 1)
Exit Sub

Errorhandler:
  If (Err.Number = 5) Then
    Err.Clear
    MsgBox "No Postscrip File Created", , "Error PostScript File"
  End If
End Sub

try it on your machine and let me know
Top Expert 2006

Commented:
this line was in your original code

vPSFileName = "c:\temp\" & vPSFileName & "ps"

and i changed it to

vPSFileName = "c:\temp\" & vPSFileName & ".ps" <---- missing dot

but that could've been a typo

Author

Commented:
While it works for most people using that code base (I tested using 5 samples) some people and systems are not able to get the yielded results. Here is the scenario as explained in another ee question.

I have a macro developed originally in Word 97 that we are now migrating over to Windows XP. On some systems, this macro will allow us to insert and save a file which is a PS to the destination drive. Unfortunately, this is not happening at some machine as it stops at a Print To File Dialogue box which request to save a file with the .prn extension. What setting in Word XP/Windows XP must be edited so that this can run automatically without breaking. Our dummy print driver is the Lithotronic 300 v47.1. An answer to this question is need as soon as possible. Thank you.
Top Expert 2006

Commented:
yes i know what was stated there, you say some systems, so it is working on several others just to be sure i get this correct

the code i tested above in the previous post worked up to a point
-but didn't ask for a filename
-and the file it tried to print was ps

only have no ps driver at this moment

Author

Commented:
its stops and asked you in a print to file save as window with the default going to prn. the system has multiple postscript dirvers, it just does not want to go past that save as window and dump the file name into the save location. the user has to intervene in the location and manual title and save. the has to be automated due to the nature of the data - no user intervention has been allowed in the past - it can not be allowed now.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial