Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2006

Tip: Looking for answers? Try searching our database.

Get MailMerge.Datasource as Document-Object?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lüko Willms - 13 Oct 2006 10:54 GMT
Is there a way to the MailMerge.DataSource as a Word-Document-Object
(when it is a Word-Document, of course), without EditDataSource and
catching the then "ActiveDocument"?

Yours,
L.W.
Jean-Guy Marcil - 13 Oct 2006 19:27 GMT
Lüko Willms was telling us:
Lüko Willms nous racontait que :

>  Is there a way to the MailMerge.DataSource as a Word-Document-Object
> (when it is a Word-Document, of course), without EditDataSource and
> catching the then "ActiveDocument"?

Try this:

Dim docMain As Document
Dim docSource As Document

Set docMain = ActiveDocument
Set docSource = Documents.Open(docMain.MailMerge.DataSource.Name)

Of course, you may need to add error checking in case the current document
is not attached to a merge source:

Dim docMain As Document
Dim docSource As Document

Set docMain = ActiveDocument
If docMain.MailMerge.DataSource.Name <> "" Then
   Set docSource = Documents.Open(docMain.MailMerge.DataSource.Name)
Else
   MsgBox "The current document is not a mailmerge type of document.", _
       vbInformation, "Error"
End If

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Doug Robbins - Word MVP - 13 Oct 2006 19:59 GMT
ActiveDocument.MailMerge.DataSource.Name

returns the path\filename of the data source attached to a mailmerge main
document.

Signature

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

>  Is there a way to the MailMerge.DataSource as a Word-Document-Object
> (when it is a Word-Document, of course), without EditDataSource and
> catching the then "ActiveDocument"?
>
> Yours,
> L.W.
Lüko Willms - 13 Oct 2006 22:04 GMT
Am Fri, 13 Oct 2006 18:59:25 UTC,  schrieb "Doug Robbins - Word MVP"
<dkr@REMOVECAPSmvps.org>  auf microsoft.public.word.vba.general :

> ActiveDocument.MailMerge.DataSource.Name
>  
> returns the path\filename of the data source attached to a mailmerge main
> document.

 Thanks for the hint.

 And then
   Set myDatasource = Documents(myMainDoc.MailMerge.Datasource.Name)

 results in the Datasource as an object.

Yours,
L.W.
Lüko Willms - 26 Oct 2006 11:20 GMT
Am Fri, 13 Oct 2006 21:04:47 UTC,  schrieb "Lüko Willms"
<l.willms@domain.invalid>  auf microsoft.public.word.vba.general :

> > ActiveDocument.MailMerge.DataSource.Name
> >  
> > returns the path\filename of the data source attached to a mailmerge main
> > document.

>   And then
>     Set myDatasource = Documents(myMainDoc.MailMerge.Datasource.Name)

   But MS-Word rejects "C:\Eigene
Dateien\mySubdirectory\myFilename.doc" as an invalid filename... at
least before the code executes an
ActiveDocument.Mailmerge.EditDatasource. It seems that
.Mailmerge.CreateDataSource does not yet create the document, only the
following .EditDataSource does. Strange, isn't it?

L.W.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.