Printing a Word doc from Access

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Stefania Scott

    Printing a Word doc from Access

    I am trying to print a word document from Access. The code I've
    written works well in my computer but does not in the one were it is
    needed.
    Here the piece of code:
    'doc path
    strObjectPath = "P:\2004workshe ets\IIS_WS.doc"

    Set oWord = New Word.Applicatio n
    oWord.Documents .Add (strObjectPath)
    oWord.PrintOut
    oWord.Quit SaveChanges:=0
    Set oWord = Nothing

    In my computer the document prints correctly and the fields in word
    that are linked to a tmpTable in Access are correctly refreshed.
    In the other computer the document prints without refreshing.
    I tried several thingd such as:


    Set oWord = New Word.Applicatio n
    oWord.Documents .Add (strObjectPath)
    'added this line to update fields in the word doc
    oWord.ActiveDoc ument.Fields.Up date
    oWord.PrintOut
    oWord.Quit SaveChanges:=0

    Another problem is that in the other computer the print Icon appeared
    but the document was not printing, I resolved the problem by adding a
    message box between PrintOut and Quit line and this has resolved the
    printing problem but not the refreshing of the linked fields.

    If any one has any idea regarding what's going on I will really
    appreciate it.

    Thanks,

    Stefania
    Set oWord = Nothing
  • Mike Preston

    #2
    Re: Printing a Word doc from Access

    On 20 Apr 2004 13:49:44 -0700, stefania@u.ariz ona.edu (Stefania Scott)
    wrote:
    [color=blue]
    >I am trying to print a word document from Access. The code I've
    >written works well in my computer but does not in the one were it is
    >needed.
    >Here the piece of code:
    > 'doc path
    > strObjectPath = "P:\2004workshe ets\IIS_WS.doc"
    >
    > Set oWord = New Word.Applicatio n
    > oWord.Documents .Add (strObjectPath)
    > oWord.PrintOut
    > oWord.Quit SaveChanges:=0
    > Set oWord = Nothing
    >
    >In my computer the document prints correctly and the fields in word
    >that are linked to a tmpTable in Access are correctly refreshed.
    >In the other computer the document prints without refreshing.
    >I tried several thingd such as:
    >
    >
    > Set oWord = New Word.Applicatio n
    > oWord.Documents .Add (strObjectPath)
    >'added this line to update fields in the word doc
    > oWord.ActiveDoc ument.Fields.Up date
    > oWord.PrintOut
    > oWord.Quit SaveChanges:=0
    >
    > Another problem is that in the other computer the print Icon appeared
    >but the document was not printing, I resolved the problem by adding a
    >message box between PrintOut and Quit line and this has resolved the
    >printing problem but not the refreshing of the linked fields.
    >
    >If any one has any idea regarding what's going on I will really
    >appreciate it.
    >
    >Thanks,
    >
    >Stefania[/color]

    On the other computer, change the Word option under:

    Tools|Options|P rint|Update Fields so that it matches yours.

    mike

    Comment

    • Stefania Scott

      #3
      Re: Printing a Word doc from Access

      Mike,
      Thank you for your reply.
      Before posting the help message I had already checked the printing
      options and it did not work; the all thing is driving me nuts.
      Furthermore, there is the fact that if I do not put the msgbox between
      printout and quit in the other computer you see the printing icon
      appear but the document does not get printed, why?. Any other possible
      suggestion on the matter?

      Stefania

      mbpatpas.invali d@pacbell.net (Mike Preston) wrote in message news:<408590e0. 342754214@news. INDIVIDUAL.NET> ...[color=blue]
      > On 20 Apr 2004 13:49:44 -0700, stefania@u.ariz ona.edu (Stefania Scott)
      > wrote:
      >[color=green]
      > >I am trying to print a word document from Access. The code I've
      > >written works well in my computer but does not in the one were it is
      > >needed.
      > >Here the piece of code:
      > > 'doc path
      > > strObjectPath = "P:\2004workshe ets\IIS_WS.doc"
      > >
      > > Set oWord = New Word.Applicatio n
      > > oWord.Documents .Add (strObjectPath)
      > > oWord.PrintOut
      > > oWord.Quit SaveChanges:=0
      > > Set oWord = Nothing
      > >
      > >In my computer the document prints correctly and the fields in word
      > >that are linked to a tmpTable in Access are correctly refreshed.
      > >In the other computer the document prints without refreshing.
      > >I tried several thingd such as:
      > >
      > >
      > > Set oWord = New Word.Applicatio n
      > > oWord.Documents .Add (strObjectPath)
      > >'added this line to update fields in the word doc
      > > oWord.ActiveDoc ument.Fields.Up date
      > > oWord.PrintOut
      > > oWord.Quit SaveChanges:=0
      > >
      > > Another problem is that in the other computer the print Icon appeared
      > >but the document was not printing, I resolved the problem by adding a
      > >message box between PrintOut and Quit line and this has resolved the
      > >printing problem but not the refreshing of the linked fields.
      > >
      > >If any one has any idea regarding what's going on I will really
      > >appreciate it.
      > >
      > >Thanks,
      > >
      > >Stefania[/color]
      >
      > On the other computer, change the Word option under:
      >
      > Tools|Options|P rint|Update Fields so that it matches yours.
      >
      > mike[/color]

      Comment

      • Stefania Scott

        #4
        Re: Printing a Word doc from Access

        Mike,
        I have noticed the following:
        when I open the word document from the computer where the automation
        does not work I get the message following message:
        Microsoft Word
        Opening this document will run the following SQL command:
        SELECT * FROM tmpWorkSheet
        Data from your database will be placed in the document. Do you want to
        continue?
        Yes No

        Is it possible that this is the cause of the problem, if so how do I
        fix it?

        Thanks again,

        Stefania

        mbpatpas.invali d@pacbell.net (Mike Preston) wrote in message news:<408590e0. 342754214@news. INDIVIDUAL.NET> ...[color=blue]
        > On 20 Apr 2004 13:49:44 -0700, stefania@u.ariz ona.edu (Stefania Scott)
        > wrote:
        >[color=green]
        > >I am trying to print a word document from Access. The code I've
        > >written works well in my computer but does not in the one were it is
        > >needed.
        > >Here the piece of code:
        > > 'doc path
        > > strObjectPath = "P:\2004workshe ets\IIS_WS.doc"
        > >
        > > Set oWord = New Word.Applicatio n
        > > oWord.Documents .Add (strObjectPath)
        > > oWord.PrintOut
        > > oWord.Quit SaveChanges:=0
        > > Set oWord = Nothing
        > >
        > >In my computer the document prints correctly and the fields in word
        > >that are linked to a tmpTable in Access are correctly refreshed.
        > >In the other computer the document prints without refreshing.
        > >I tried several thingd such as:
        > >
        > >
        > > Set oWord = New Word.Applicatio n
        > > oWord.Documents .Add (strObjectPath)
        > >'added this line to update fields in the word doc
        > > oWord.ActiveDoc ument.Fields.Up date
        > > oWord.PrintOut
        > > oWord.Quit SaveChanges:=0
        > >
        > > Another problem is that in the other computer the print Icon appeared
        > >but the document was not printing, I resolved the problem by adding a
        > >message box between PrintOut and Quit line and this has resolved the
        > >printing problem but not the refreshing of the linked fields.
        > >
        > >If any one has any idea regarding what's going on I will really
        > >appreciate it.
        > >
        > >Thanks,
        > >
        > >Stefania[/color]
        >
        > On the other computer, change the Word option under:
        >
        > Tools|Options|P rint|Update Fields so that it matches yours.
        >
        > mike[/color]

        Comment

        • Mike Preston

          #5
          Re: Printing a Word doc from Access

          On 21 Apr 2004 07:29:03 -0700, stefania@u.ariz ona.edu (Stefania Scott)
          wrote:
          [color=blue]
          >Mike,
          >Thank you for your reply.
          >Before posting the help message I had already checked the printing
          >options and it did not work; the all thing is driving me nuts.
          >Furthermore, there is the fact that if I do not put the msgbox between
          >printout and quit in the other computer you see the printing icon
          >appear but the document does not get printed, why?. Any other possible
          >suggestion on the matter?[/color]

          I'm not going to be much help at this point, I'm afraid.

          It sounds like the other computer's setup is significantly different
          from yours. The msgbox insertion seems to slow things down enough for
          the printing to take place before the Access VBA finishes. I would
          think the "oWord.PrintOut " command would be interpreted by Word as
          something that must be completed before it would allow the "oWord.Quit
          SaveChanges:=0" to be executed, but obviously not.

          Again, it points to Word's set-up on the offending computer. Is there
          an option that disallows background printing?

          mike

          [color=blue]
          >
          >Stefania
          >
          >mbpatpas.inval id@pacbell.net (Mike Preston) wrote in message news:<408590e0. 342754214@news. INDIVIDUAL.NET> ...[color=green]
          >> On 20 Apr 2004 13:49:44 -0700, stefania@u.ariz ona.edu (Stefania Scott)
          >> wrote:
          >>[color=darkred]
          >> >I am trying to print a word document from Access. The code I've
          >> >written works well in my computer but does not in the one were it is
          >> >needed.
          >> >Here the piece of code:
          >> > 'doc path
          >> > strObjectPath = "P:\2004workshe ets\IIS_WS.doc"
          >> >
          >> > Set oWord = New Word.Applicatio n
          >> > oWord.Documents .Add (strObjectPath)
          >> > oWord.PrintOut
          >> > oWord.Quit SaveChanges:=0
          >> > Set oWord = Nothing
          >> >
          >> >In my computer the document prints correctly and the fields in word
          >> >that are linked to a tmpTable in Access are correctly refreshed.
          >> >In the other computer the document prints without refreshing.
          >> >I tried several thingd such as:
          >> >
          >> >
          >> > Set oWord = New Word.Applicatio n
          >> > oWord.Documents .Add (strObjectPath)
          >> >'added this line to update fields in the word doc
          >> > oWord.ActiveDoc ument.Fields.Up date
          >> > oWord.PrintOut
          >> > oWord.Quit SaveChanges:=0
          >> >
          >> > Another problem is that in the other computer the print Icon appeared
          >> >but the document was not printing, I resolved the problem by adding a
          >> >message box between PrintOut and Quit line and this has resolved the
          >> >printing problem but not the refreshing of the linked fields.
          >> >
          >> >If any one has any idea regarding what's going on I will really
          >> >appreciate it.
          >> >
          >> >Thanks,
          >> >
          >> >Stefania[/color]
          >>
          >> On the other computer, change the Word option under:
          >>
          >> Tools|Options|P rint|Update Fields so that it matches yours.
          >>
          >> mike[/color][/color]

          Comment

          • Mike Preston

            #6
            Re: Printing a Word doc from Access

            On 21 Apr 2004 08:19:15 -0700, stefania@u.ariz ona.edu (Stefania Scott)
            wrote:
            [color=blue]
            >Mike,
            >I have noticed the following:
            >when I open the word document from the computer where the automation
            >does not work I get the message following message:
            >Microsoft Word
            >Opening this document will run the following SQL command:
            >SELECT * FROM tmpWorkSheet
            >Data from your database will be placed in the document. Do you want to
            >continue?
            >Yes No
            >
            >Is it possible that this is the cause of the problem, if so how do I
            >fix it?[/color]

            Well, it seems like the other computer's Word is set up to mandate
            some form of validation before the fields are updated. That could
            certainly explain why the automation code doesn't update the fields -
            it isn't providing the proper validation.

            Again, it looks like the Word installation on the offending computer
            is the culprit. Maybe a word newsgroup would be more familiar with
            the issues.

            mike
            [color=blue]
            >
            >mbpatpas.inval id@pacbell.net (Mike Preston) wrote in message news:<408590e0. 342754214@news. INDIVIDUAL.NET> ...[color=green]
            >> On 20 Apr 2004 13:49:44 -0700, stefania@u.ariz ona.edu (Stefania Scott)
            >> wrote:
            >>[color=darkred]
            >> >I am trying to print a word document from Access. The code I've
            >> >written works well in my computer but does not in the one were it is
            >> >needed.
            >> >Here the piece of code:
            >> > 'doc path
            >> > strObjectPath = "P:\2004workshe ets\IIS_WS.doc"
            >> >
            >> > Set oWord = New Word.Applicatio n
            >> > oWord.Documents .Add (strObjectPath)
            >> > oWord.PrintOut
            >> > oWord.Quit SaveChanges:=0
            >> > Set oWord = Nothing
            >> >
            >> >In my computer the document prints correctly and the fields in word
            >> >that are linked to a tmpTable in Access are correctly refreshed.
            >> >In the other computer the document prints without refreshing.
            >> >I tried several thingd such as:
            >> >
            >> >
            >> > Set oWord = New Word.Applicatio n
            >> > oWord.Documents .Add (strObjectPath)
            >> >'added this line to update fields in the word doc
            >> > oWord.ActiveDoc ument.Fields.Up date
            >> > oWord.PrintOut
            >> > oWord.Quit SaveChanges:=0
            >> >
            >> > Another problem is that in the other computer the print Icon appeared
            >> >but the document was not printing, I resolved the problem by adding a
            >> >message box between PrintOut and Quit line and this has resolved the
            >> >printing problem but not the refreshing of the linked fields.
            >> >
            >> >If any one has any idea regarding what's going on I will really
            >> >appreciate it.
            >> >
            >> >Thanks,
            >> >
            >> >Stefania[/color]
            >>
            >> On the other computer, change the Word option under:
            >>
            >> Tools|Options|P rint|Update Fields so that it matches yours.
            >>
            >> mike[/color][/color]

            Comment

            Working...