|
|
Word Automation from Access
I am trying to output some fields from a table to a word merge document. I
have created the word document. When I run my code I get an error at the
".OpendataSource (strTableName). The error says it cannot find the "file". I
know the table is there. Any suggestions? Any help would be appreciated>my
coding is as follows:
Sub MergeWord(strReportName, strTableName)
Dim dbs As DAO.Database
Dim wApp As Object
Dim wDoc As Object
Dim wActiveDoc As Word.Document
Set dbs = CurrentDb
Set wApp = CreateObject("Word.Application")
Set wDoc = wApp.Documents.Open(strReportName)
With wDoc.MailMerge
.OpenDataSource (strTableName)
.Destination = wdSendToNewDocument
.Execute
End With
Set wActiveDoc = wApp.ActiveDocument
wActiveDoc.Visible = True
Set dbs = Nothing
Set rst = Nothing
Set wApp = Nothing
Set wDoc = Nothing
Set wActiveDoc = Nothing
End Sub
Thank You
|
|
0
|
|
|
|
Reply
|
Utf
|
2/21/2008 8:19:01 PM |
|
Shouldn't you provide the location of the strReportName. My guess is that the
file can be found but your routine doesn't know where to look for it...
maybe something like:
Set wDoc = wApp.Documents.Open("c:\your location\ " & strReportName)
hth
--
Maurice Ausum
"AJ" wrote:
> I am trying to output some fields from a table to a word merge document. I
> have created the word document. When I run my code I get an error at the
> ".OpendataSource (strTableName). The error says it cannot find the "file". I
> know the table is there. Any suggestions? Any help would be appreciated>my
> coding is as follows:
>
> Sub MergeWord(strReportName, strTableName)
>
> Dim dbs As DAO.Database
> Dim wApp As Object
> Dim wDoc As Object
> Dim wActiveDoc As Word.Document
>
> Set dbs = CurrentDb
> Set wApp = CreateObject("Word.Application")
>
> Set wDoc = wApp.Documents.Open(strReportName)
> With wDoc.MailMerge
> .OpenDataSource (strTableName)
> .Destination = wdSendToNewDocument
> .Execute
> End With
> Set wActiveDoc = wApp.ActiveDocument
> wActiveDoc.Visible = True
>
> Set dbs = Nothing
> Set rst = Nothing
> Set wApp = Nothing
> Set wDoc = Nothing
> Set wActiveDoc = Nothing
>
> End Sub
>
> Thank You
|
|
0
|
|
|
|
Reply
|
Utf
|
2/21/2008 8:33:00 PM
|
|
I pass the location in the call statement of another module. It is actually
the table that the error code says it cannot find..Which I pass also in the
call statement.
"Maurice" wrote:
> Shouldn't you provide the location of the strReportName. My guess is that the
> file can be found but your routine doesn't know where to look for it...
>
> maybe something like:
>
> Set wDoc = wApp.Documents.Open("c:\your location\ " & strReportName)
>
> hth
> --
> Maurice Ausum
>
>
> "AJ" wrote:
>
> > I am trying to output some fields from a table to a word merge document. I
> > have created the word document. When I run my code I get an error at the
> > ".OpendataSource (strTableName). The error says it cannot find the "file". I
> > know the table is there. Any suggestions? Any help would be appreciated>my
> > coding is as follows:
> >
> > Sub MergeWord(strReportName, strTableName)
> >
> > Dim dbs As DAO.Database
> > Dim wApp As Object
> > Dim wDoc As Object
> > Dim wActiveDoc As Word.Document
> >
> > Set dbs = CurrentDb
> > Set wApp = CreateObject("Word.Application")
> >
> > Set wDoc = wApp.Documents.Open(strReportName)
> > With wDoc.MailMerge
> > .OpenDataSource (strTableName)
> > .Destination = wdSendToNewDocument
> > .Execute
> > End With
> > Set wActiveDoc = wApp.ActiveDocument
> > wActiveDoc.Visible = True
> >
> > Set dbs = Nothing
> > Set rst = Nothing
> > Set wApp = Nothing
> > Set wDoc = Nothing
> > Set wActiveDoc = Nothing
> >
> > End Sub
> >
> > Thank You
|
|
0
|
|
|
|
Reply
|
Utf
|
2/25/2008 2:16:01 PM
|
|
"ROSCECAN@ HOT MAIL.COM" <ROSCECAN@ HOT MAIL.COM> wrote in message
news:OstVKrQiIHA.4844@TK2MSFTNGP06.phx.gbl...
>
>
> "AJ" <AJ@discussions.microsoft.com> escreveu na not�cia da
> mensagem:7F2C6522-5472-4E1E-BF63-A543773024E1@microsoft.com...
>> I am trying to output some fields from a table to a word merge document.
>> I
>> have created the word document. When I run my code I get an error at the
>> ".OpendataSource (strTableName). The error says it cannot find the
>> "file". I
>> know the table is there. Any suggestions? Any help would be
>> appreciated>my
>> coding is as follows:
>>
>> Sub MergeWord(strReportName, strTableName)
>>
>> Dim dbs As DAO.Database
>> Dim wApp As Object
>> Dim wDoc As Object
>> Dim wActiveDoc As Word.Document
>>
>> Set dbs = CurrentDb
>> Set wApp = CreateObject("Word.Application")
>>
>> Set wDoc = wApp.Documents.Open(strReportName)
>> With wDoc.MailMerge
>> .OpenDataSource (strTableName)
>> .Destination = wdSendToNewDocument
>> .Execute
>> End With
>> Set wActiveDoc = wApp.ActiveDocument
>> wActiveDoc.Visible = True
>>
>> Set dbs = Nothing
>> Set rst = Nothing
>> Set wApp = Nothing
>> Set wDoc = Nothing
>> Set wActiveDoc = Nothing
>>
>> End Sub
>>
>> Thank You
>
|
|
0
|
|
|
|
Reply
|
leoladouceur
|
3/18/2008 10:11:05 PM
|
|
"AJ" <AJ@discussions.microsoft.com> escreveu na not�cia da
mensagem:7F2C6522-5472-4E1E-BF63-A543773024E1@microsoft.com...
> I am trying to output some fields from a table to a word merge document. I
> have created the word document. When I run my code I get an error at the
> ".OpendataSource (strTableName). The error says it cannot find the "file".
> I
> know the table is there. Any suggestions? Any help would be appreciated>my
> coding is as follows:
>
> Sub MergeWord(strReportName, strTableName)
>
> Dim dbs As DAO.Database
> Dim wApp As Object
> Dim wDoc As Object
> Dim wActiveDoc As Word.Document
>
> Set dbs = CurrentDb
> Set wApp = CreateObject("Word.Application")
>
> Set wDoc = wApp.Documents.Open(strReportName)
> With wDoc.MailMerge
> .OpenDataSource (strTableName)
> .Destination = wdSendToNewDocument
> .Execute
> End With
> Set wActiveDoc = wApp.ActiveDocument
> wActiveDoc.Visible = True
>
> Set dbs = Nothing
> Set rst = Nothing
> Set wApp = Nothing
> Set wDoc = Nothing
> Set wActiveDoc = Nothing
>
> End Sub
>
> Thank You
|
|
0
|
|
|
|
Reply
|
ROSCECAN
|
3/19/2008 3:15:18 PM
|
|
|
4 Replies
323 Views
(page loaded in 0.002 seconds)
Similiar Articles: Word Automation from Access - microsoft.public.accessWord Automation Problem - microsoft.public.access Hi, I am trying to use Word as a report writer via automation from Access. I am trying to print an invoice that ... Word Automation Problem - microsoft.public.accessHi, I am trying to use Word as a report writer via automation from Access. I am trying to print an invoice that contains pre-defined bookmar... How to Automate Word mail merge from AC2007? - microsoft.public ...Word Automation from Access - microsoft.public.access How to Automate Word mail merge from AC2007? - microsoft.public ... Word Automation from Access - microsoft.public ... Access - Outlook Mail Automation: SendUsingAccount - microsoft ...Word Automation from Access - microsoft.public.access Access - Outlook Mail Automation: SendUsingAccount - microsoft ... Word Automation from Access - microsoft.public ... displaying hyperlink in automation to Word - microsoft.public ...I have a field in a table that shows hyperlinks with a different caption (i.e. if the web address is www.pbs.org, I display the link as "PBS"), but wh... Word Automation - microsoft.public.windows.powershellWord Automation from Access - microsoft.public.access Word Automation Problem - microsoft.public.access Hi, I am trying to use Word as a report writer via automation from ... Word 2007 automation - setting default conversion for InsertFile ...Word Automation from Access - microsoft.public.access Word 2007 automation - setting default conversion for InsertFile ... Word Automation from Access - microsoft.public ... Word Automation Export toWord Problems - microsoft.public.dotnet ...Word Automation Problem - microsoft.public.access Word Automation Export toWord Problems - microsoft.public.dotnet ... Hi , I am using word Automation to export to word . Excel Automation, Cell Border Lines - microsoft.public.access ...I am trying to figure out how to put border lines around each cell in my excel data. I am using automation from access but the code I am using is on... Automating 'From' - microsoft.public.access.formscoding ...Word Automation from Access - microsoft.public.access Word Automation Problem - microsoft.public.access Hi, I am trying to use Word as a report writer via automation from ... Word Automation from Access - Part I - Accessing Word From AccessWord Automation, Part I . Accessing Word From Inside Access . By Bryan Carbonnell. Demo File . Have you ever wanted to use the formatting control in Word on one of ... How to Transfer Data From Access to Word by Automation | eHow.comMicrosoft Word documents with frequently updated table data benefit from automation. Word and Access work together by forming a link. This link takes data from the ... Word Automation from Access - Part II – Inserting Text Into Word ...Word Automation, Part II . Inserting Text into Word Bookmarks . By Bryan Carbonnelle. Demo File . In the last article we reviewed a number of automation tasks for ... How to Work With Word Documents From Access Using Automation ...One of the most useful features of Microsoft Access is its ability to integrate seamlessly with other Office programs. By using macro automation, users can open other ... MS Word Automation from MS AccessMicrosoft Word© Automation from Microsoft Access© MS Office Versions 2000 & 2002 by Ofer Shimrat for AUGSD Introduction Microsoft Office Automation Environment ... 7/31/2012 6:10:32 AM
|
|
|
|
|
|
|
|
|