View Single Post
  #7   Report Post  
Ed B
 
Posts: n/a
Default

Cindy,

I tried your suggested macro and got the following error messages:

Sub MergeStandardLetter2()
Dim wd as Word.Application
Dim doc aS Word.Document

Set wd = new Word.Application
wd.Visible = True
Set doc = wd.Documents.Open( _
FileName:="G:\Regulatory\Form Letters\Standard.doc", _
ConfirmConversions:=False, _
ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto)
With doc.MailMerge
..Destination = wd.wdSendToNewDocument
..SuppressBlankLines = True
With .DataSource
..FirstRecord = wd.wdDefaultFirstRecord
..LastRecord = wd.wdDefaultLastRecord
End With
..Execute Pause:=False
End With
Set doc = Nothing
Set wd = Nothing
End Sub

Compile Error: Method or Data Member Not Found

I had to remove the "md." from the following lines to get it to compile
.Destination = wd.wdSendToNewDocument
.FirstRecord = wd.wdDefaultFirstRecord
.LastRecord = wd.wdDefaultLastRecord

After I did that, I tried to run the macro, and got the following error
"Run-Time error '5852' Requested object is not available"

and the debugger highlighted the following line of code:
..Destination = wdSendToNewDocument

What could be the problem, as it works fine in the recorded macro I did in
Word?

--
Have a nice day, Ed


"Cindy M -WordMVP-" wrote:

Hi ?B?RWQgQg==?=,

The SendKeys statement (SendKeys = +%TLM~G:\Regulatory\Form
Letters\Standard.doc~%(trmm) ) shows the strokes to open Word. the Tools,
Links, Merge it with Word command is the one called. This coupled with the
call of the Standard document used to be enough to open Word and Merge the
data from the Access table.

Shift+Alt+T, followed by L and then M opens Word? What menu commands are these
in Access?

Not that it matters, I suppose, because you won't be able to go this route to
do any sensible automation... Automating another application is not a trivial
thing for someone with minimal programming experience, but let's see...

You need to copy this to an ACCESS module and test. I'm not going to guarantee
that I won't make any typing/syntax errors.

Before you try to run it, you need to go to the Tools/References menu in the
VB Editor and activate the checkbox for "Microsoft Word 10" (or similar).

If you get error messages, be sure to quote the full and exact text in your
reply, and indicate on which line it occurs.

Sub MergeStandardLetter2()
Dim wd as Word.Application
Dim doc aS Word.Document

Set wd = new Word.Application
wd.Visible = True
Set doc = wd.Documents.Open( _
FileName:="G:\Regulatory\Form Letters\Standard.doc", _
ConfirmConversions:=False, _
ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto)
With doc.MailMerge
.Destination = wd.wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wd.wdDefaultFirstRecord
.LastRecord = wd.wdDefaultLastRecord
End With
.Execute Pause:=False
End With
Set doc = Nothing
Set wd = Nothing
End Sub

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)