Re: Starting MSWord Merge from MSAccess by Kathy
Kathy
Mon Dec 03 09:48:33 PST 2007
Unfortunately, it didn't like either of those, but I messed with it, and it
likes:
wd.ActiveDocument.SaveAs "K:\legalper\merged_ad.doc", _
0, False, "", False, "", False, False, False, False, False
Thank you!
"Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
news:%2353kvt7MIHA.4480@TK2MSFTNGP06.phx.gbl...
> Use
>
> wd.ActiveDocument.SaveAs "K:\legalper\merged_ad.doc",
> SaveToRecentFiles: = False
>
> or, as you seem to have had troubled with using named parameters, you may
> need to use
>
> wd.ActiveDocument.SaveAs "K:\legalper\merged_ad.doc","","","", False
>
>
>
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP
>
> "Kathy Webster" <slickdock@yahoo.com> wrote in message
> news:47509462$0$16483$4c368faf@roadrunner.com...
>> You da bomb...Thanks!
>> One last question...I hope...
>> How do I modify this line you gave me, so that "merged_ad.doc" doesn't
>> show up on the recently edited docs list?
>>
>> wd.ActiveDocument.SaveAs "K:\legalper\merged_ad.doc"
>>
>> "Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
>> news:OMl6yW4MIHA.5160@TK2MSFTNGP05.phx.gbl...
>>> Earlier in your code, you have turned off ScreenUpdating
>>>
>>> Try adding the following at the end.
>>>
>>> wd.ScreenUpdating = True
>>> wd.ScreenRefresh
>>> wd.ActiveDocument.Close
>>> wd.Documents.Add
>>>
>>> --
>>> Hope this helps.
>>>
>>> Please reply to the newsgroup unless you wish to avail yourself of my
>>> services on a paid consulting basis.
>>>
>>> Doug Robbins - Word MVP
>>>
>>> "Kathy Webster" <slickdock@yahoo.com> wrote in message
>>> news:47504432$0$8823$4c368faf@roadrunner.com...
>>>> Cool, thanks. I had make 1 change to this line:
>>>>
>>>> wdActiveDoc.Close wdDoNotSaveChanges
>>>>
>>>> to
>>>>
>>>> wdActiveDoc.Close , 0
>>>>
>>>> because it didn't understand wdDoNotSaveChanges
>>>>
>>>> One last thing: Now my Word screen is left with "merged_ad.doc" in the
>>>> title bar, and the screen is inactive (gray background, no white "sheet
>>>> of paper" ready to go). How can I leave Word with no document in the
>>>> title bar and a white "Sheet of paper" on the screen?
>>>>
>>>>
>>>>
>>>>
>>>> "Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
>>>> news:O2ZbikxMIHA.5988@TK2MSFTNGP02.phx.gbl...
>>>>> In place of
>>>>>
>>>>> wd.Windows("merge_ad.doc ").Activate
>>>>> wd.ActiveWindow.Close 0
>>>>> wdActiveDoc.saveas Filename:="K:\legalper\merged_ad.doc"
>>>>>
>>>>> use
>>>>>
>>>>> wdActiveDoc.Close wdDoNotSaveChanges
>>>>> wd.ActiveDocument.SaveAs "K:\legalper\merged_ad.doc"
>>>>>
>>>>> --
>>>>> Hope this helps.
>>>>>
>>>>> Please reply to the newsgroup unless you wish to avail yourself of my
>>>>> services on a paid consulting basis.
>>>>>
>>>>> Doug Robbins - Word MVP
>>>>>
>>>>> "Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
>>>>> news:eGhrj0rMIHA.484@TK2MSFTNGP06.phx.gbl...
>>>>>> In place of
>>>>>>
>>>>>> wd.Windows("merge_ad.doc ").Activate
>>>>>> wd.ActiveWindow.Close 0
>>>>>>
>>>>>> use
>>>>>>
>>>>>> wdActiveDoc.Close wdDoNotSaveChanges
>>>>>>
>>>>>> Note, you do not show that you have declared wdActiveDoc as a
>>>>>> document object.
>>>>>>
>>>>>> --
>>>>>> Hope this helps.
>>>>>>
>>>>>> Please reply to the newsgroup unless you wish to avail yourself of my
>>>>>> services on a paid consulting basis.
>>>>>>
>>>>>> Doug Robbins - Word MVP
>>>>>>
>>>>>> "Kathy Webster" <slickdock@yahoo.com> wrote in message
>>>>>> news:474f0729$0$2338$4c368faf@roadrunner.com...
>>>>>>>I am collecting info from an MSAccess record and trying to merge it
>>>>>>>in Word. I would like this to work with any version of Word that the
>>>>>>>user may have installed. My MSAccess app will be a runtime app that
>>>>>>>I will be putting on various machines in different workplaces.
>>>>>>> Here is the code I am running from MSAccess:
>>>>>>>
>>>>>>> Public Function AddressBlock() As Boolean
>>>>>>>
>>>>>>> Dim wd As Object
>>>>>>> Dim wdActiveDoc As Object 'RM: Added this to help ensure that
>>>>>>> you're
>>>>>>> 'working on the document you intend to.
>>>>>>> Dim wdField As Object 'RM: Note the change in name here to avoid
>>>>>>> 'ambiguity with the Field object in both
>>>>>>> Word and
>>>>>>> 'Access. As well, I changed the type,
>>>>>>> since
>>>>>>> '(like Word.Application), you have to use
>>>>>>> late
>>>>>>> 'binding.
>>>>>>>
>>>>>>> Set wd = CreateObject("Word.Application")
>>>>>>> wd.Visible = True
>>>>>>>
>>>>>>> wd.Application.ScreenUpdating = False
>>>>>>>
>>>>>>> Set wdActiveDoc = wd.Documents.Open("K:\legalper\merge_ad.doc ",
>>>>>>> False, False, _
>>>>>>> False, "", "", False, "", "", 0)
>>>>>>>
>>>>>>> With wdActiveDoc.MailMerge
>>>>>>> .Destination = 0
>>>>>>> .Execute
>>>>>>> End With
>>>>>>> wd.Windows("merge_ad.doc ").Activate
>>>>>>> wd.ActiveWindow.Close 0
>>>>>>> 'It bombs here with "Automation error: The object invoked has
>>>>>>> disconnected from its clients", and the next line is highlighted.
>>>>>>> 'What I'm trying to do here is open merge_ad.doc, merge it, close
>>>>>>> merge_ad.doc, then save the
>>>>>>> 'resulting merged doc as "merged_ad.doc"
>>>>>>> wdActiveDoc.saveas Filename:="K:\legalper\merged_ad.doc",
>>>>>>> FileFormat:=0
>>>>>>>
>>>>>>> Thanks in advance,
>>>>>>> Kathy
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>