Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Sep 2002
    Thanked 0 Times in 0 Posts

    W97 to WXP macro no longer functioning (2002/XP)

    In Word 97, we've had a macro working for years that would save the document out as a text file (based on tags) and postscript for placement on our Internet. We are unable to get this macro to function in Word XP. Instead of reading the code and auto assigning the document name, it stops and prompts the user to type it in. Once they do and click OK, the rest of the macro runs. We've been using the "sendkeys" to accomplish this. The existing code is as follows:

    Sub SaveAs_Ps() 'saves file to q:inet as postscript file
    On Error GoTo Errorhandler
    vQuote = """"
    vInitialPrinter = ActivePrinter()

    vPSFileName = ActiveDocument.Name
    vPSFileName = Left(vPSFileName, Len(vPSFileName) - 3)
    vPSFileName = "q:inet" & vPSFileName & "ps"
    vPSFileName = vQuote & vPSFileName & vQuote
    SendKeys vPSFileName & "{Enter}"
    ActivePrinter = "Linotronic 300 v47.1"
    Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
    wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
    Collate:=True, Background:=True
    ActivePrinter = vInitialPrinter
    vPSFileName = Left(vPSFileName, Len(vPSFileName) - 1) 'strip off extra quotes
    vPSFileName = Right(vPSFileName, Len(vPSFileName) - 1)
    Exit Sub

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

    Sub SaveAs_Txt() ' saves file to q:inet as ASCII file
    'response needed to assure that job has been tagged,
    'because the code in sub saveas_doc searches for <ProgNo>
    'and based on results of search saves the job in qrograms
    'or qnetime
    Response = MsgBox("JOB MUST BE TAGGED BEFORE SAVING " & _
    "TO THE Q:INETDIR. " & (Chr(13)) & (Chr(13)) & _
    "Please read below before proceeding. " & (Chr(13)) & (Chr(13)) & _
    "If job is tagged, click Yes to continue. " & (Chr(13)) & (Chr(13)) & _
    "If job is NOT tagged, click No, the procedure " & _
    "will end. Tag the job and click the INetDir Icon again.", vbYesNo, "INETDIR ICON")
    If Response = vbYes Then
    vFilename = ActiveDocument.Name
    vFilename = Left(vFilename, Len(vFilename) - 3)
    vFilename = vFilename & "txt"
    ChangeFileOpenDirectory "q:inet"
    ActiveDocument.SaveAs FileName:=vFilename, FileFormat:=wdFormatDOSText, _
    LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
    :="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
    SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
    Exit Sub
    End If
    End Sub

    Any suggestions why this might not work in Word XP?

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Silicon Valley, USA
    Thanked 94 Times in 90 Posts

    Re: W97 to WXP macro no longer functioning (2002/XP)

    SendKeys always is touchy. I assume it is the Application.PrintOut method call that is generating the dialog. If so, if you put the SendKeys line immediately before that line, does it help?

    Next question: why not specify the file name as part of the PrintOut method call?

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

    If you can bypass SendKeys altogether, life will be much more reliable. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts