Results 1 to 10 of 10
  1. #1
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ActiveDocument.Printout problem (Word 97 SR2 VBA)

    I would suggest showing us your code so we can see if our brains can figure it out...
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: ActiveDocument.Printout problem (Word 97 SR2 VBA)

    Just a quick suggestion (in the absence of a sample):

    what happens if you use Word.ActiveDocument.Printout?

  3. #3
    chris.smith
    Guest

    Re: ActiveDocument.Printout problem (Word 97 SR2 VBA)

    The code in the word document is attached to the OpenDocument event, and is as follows:

    Option Explicit
    Private Sub Document_Open()
    '
    ' This code runs when the document is first opened.
    ' We want to ensure that the data source is pointing
    ' to the right file. Then we merge, print, and close.
    '
    Dim strDataSourceName As String
    Dim strPath As String
    Dim strDataSourcePathAndName As String
    Dim objXl As Object

    strPath = ActiveDocument.Path
    strDataSourceName = "ManifestExcelForWord.XLS"
    strDataSourcePathAndName = strPath & "" & strDataSourceName

    ActiveDocument.MailMerge.OpenDataSource Name:= _
    strDataSourcePathAndName, _
    ConfirmConversions:=False, _
    ReadOnly:=False, _
    LinkToSource:=True, _
    AddToRecentFiles:=False, _
    PasswordDocument:="", _
    PasswordTemplate:="", _
    WritePasswordDocument:="", _
    WritePasswordTemplate:="", _
    Revert:=False, _
    Format:=wdOpenFormatAuto, _
    Connection:="Entire Spreadsheet", _
    SQLStatement:="", _
    SQLStatement1:=""

    With ActiveDocument.MailMerge
    .Destination = wdSendToNewDocument
    .Execute
    End With

    ActiveDocument.PrintOut

    Application.Quit (False)

    End Sub

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ActiveDocument.Printout problem (Word 97 SR2 VBA)

    Chris,

    Try some troubleshooting by using the Print dialog instead
    of .printout.

    dialogs(wdDialogFilePrint).show

    should do for testing...

    Verify that the dialog opened over the document you want to print. Verify the print range, Print What?, AND the Printer Name, etc. If all ok, print. Did it print?
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  5. #5
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ActiveDocument.Printout problem (Word 97 SR2 VBA)

    Gary,

    We've got some code here now. Give it a look...
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  6. #6
    chris.smith
    Guest

    Re: ActiveDocument.Printout problem (Word 97 SR2 VBA)

    Everything worked fine using the dialog.

    Well, atleast exactly as I expected it to.

  7. #7
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ActiveDocument.Printout problem (Word 97 SR2 VBA)

    Chris,

    Do me a favor. Edit the original post and add Resolved:
    to the front of the Subject line.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  8. #8
    chris.smith
    Guest

    Resolved: ActiveDocument.Printout problem

    I have been asked to create a couple of files to assist a customer with filling in a pre-printed form. I have to use Excel '97 for data entry and Word '97 to do the printing.

    I have the data entry going fine. When the customer is done they click a button. The VBA macro in Excel then creates a separate excel spreadsheet for a mail-merge document. This excel macro then starts up Word and has word open up a shell document.

    Word opens up this shell, the VBA on the open event merges with the data that the customer has entered, and prints out the data in the right places on the form.

    Except when I try to automate it.

    If I open the document by itself, and do the steps manually, it all works exactly as I expect. When I go to print I get a messsage about the print area being outside the range of the borders. I click 'ok' and it prints fine. And lines up perfectly.

    When I try to automate this with VBA it doesn't want to work!

    When the document is opened, it asks about whether or not you want macros enabled. I click enable macros. It then opens the shell, does the merge, does the print, and closes itself down.

    Except the print never comes out of the printer, and I was never asked about the print area / margin error.

    There is no error on the screen at all. I am trying to print the document with ActiveDocument.Printout, and I can post the entire macro if that would help.

    Can someone please assist me with this ? This is driving me nuts.

    As an addendum, this problem is on Windows NT 4 SP 6a. This macro runs fine on Windows ME and windows 2000.

  9. #9
    chris.smith
    Guest

    Re: ActiveDocument.Printout problem (Word 97 SR2 VBA)

    By your command. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  10. #10
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ActiveDocument.Printout problem (Word 97 SR2 VBA)

    Tre cool.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

Posting Permissions

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