LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Excel Automated Mailmerge with an Embedded OLE Word Object

Hello Chaps,

Am hoping that some of your genius might rub off on me, but Ive a
doozer here that am just bashing my head against the wall with.

Basically, am attempting to Automate a mailmerge within Excel, using
an embedded Word Document. The workbook just needs a sheet named
'Mailmerge' to use the below code.

All seemed to be working fine, upto the point where I want to trigger
some VB with the Private Sub Document_Open() event that sites within
the embedded word doc.

You would think I could automate the mailmerge by simply connecting to
the saved excel file (by default I save it to C:\) but... for some
reason the Private Sub Document_Open() is not being triggered. The
code within this as follows:

(btw: I can exicute each line in the immediate window and the merge
happens as desired!)

Private Sub Document_Open()

ActiveDocument.MailMerge.MainDocumentType = wdNotAMergeDocument
ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
ActiveDocument.MailMerge.Destination = wdSendToNewDocument

ActiveDocument.MailMerge.OpenDataSource Name:="C:
\FeesDecMailfile.xls", _
ConfirmConversions:=False, ReadOnly:=False,
LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="",
PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="",
Revert:=False, _
Format:=wdOpenFormatAuto, Connection:= _
"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";Us er
ID=Admin;Data Source=C:\FeesDecMailfile.xls;Mode=Read;Extended
Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet
OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet
OLEDB:Engine Type=35;J" _
, SQLStatement:="SELECT * FROM `Mailmerge$`",
SQLStatement1:="", SubType _
:=wdMergeSubTypeAccess

With ActiveDocument.MailMerge
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With


A simple debug excercise of simply calling a msgbox on the first line
results in nothing being displayed!

All I can assume is that there are no events being triggered when an
OLE doc is opened!! but surely not?!? Ive scoured the net but to no
avail.

Any pointers? :\


Help me Obi Wan...

regards,

David

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy text with formatting from an Excel cell into an embedded Word object? [email protected] Excel Programming 0 January 8th 07 05:32 PM
Word with embedded Excel object which has reference to addin Tom Chau Excel Discussion (Misc queries) 0 September 6th 06 02:25 AM
Reference to an Embedded Word Object [email protected] Excel Programming 2 April 20th 06 03:05 PM
Cannor strech embedded word object BartDesc Excel Discussion (Misc queries) 2 March 10th 06 08:15 AM
MailMerge using a word object nath Excel Programming 0 May 27th 04 03:51 PM


All times are GMT +1. The time now is 09:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"