Solved

Export Access to Word template

Posted on 2008-10-29
3
1,377 Views
Last Modified: 2012-05-05
I  export an access report to a Word Template. Everything is working great.
With the installation of another computer, we want to share the database between the computers, too. Even that is working! The database and the templates are in a Mapped folder.
If I try to create the Word document from the "external" computer, the  code line
'Set doc = wrdApp.Documents.Add(strPath & contemplate)'  is set to NULL. The path and the file name are correct and can be monitored in step mode.
All computers have the right to read and write to the shared drive!
The "external" computer can regerate the word file with the data as a table in it (RTF file)!!
Who can help me?

Josh




    ' Export the data to rtf format
    DoCmd.OutputTo acOutputQuery, conquery, _
     acFormatRTF, strDataSource, False

    ' Start Word using mailmerge template
    Set wrdApp = New Word.Application
    Set doc = wrdApp.Documents.Add(strPath & contemplate)   '<<<======
   
    ' Do the mail merge to a new document.
    With doc.MailMerge
        .OpenDataSource Name:=strDataSource
        .Destination = wdSendToNewDocument
        .SuppressBlankLines = True
        With .DataSource
            .FirstRecord = wdDefaultFirstRecord
            .LastRecord = wdDefaultLastRecord
        End With
        If .State = wdMainAndDataSource Then
            .Execute
        End If
    End With
   
    ' Display the mail merge document
    wrdApp.Visible = True
    wrdApp.WindowState = wdWindowStateMaximize
 
ExitHere:
    doc.Close (wdDoNotSaveChanges)
    Set doc = Nothing
   
    Set wrdApp = Nothing
    Exit Sub
   
HandleErrors:   etc. etc. etc.
0
Comment
Question by:jojahn
  • 2
3 Comments
 
LVL 21

Expert Comment

by:oleggold
ID: 22833226
did You try to add word object to Your vb project?
0
 
LVL 21

Expert Comment

by:oleggold
ID: 22833250
at least Microsoft Office object library,I mean,on external computer
0
 

Accepted Solution

by:
jojahn earned 0 total points
ID: 22840630
The references are the same.
If I copy the database to the external computer and run it, it uses the current path etc...and if the template is there , the software works again.
Here is the code before.....

    Dim strPath As String
    Dim strDataSource As String
   
    Dim doc As Word.Document
    Dim wrdApp As Word.Application
      Const contemplate As String = "Template_1"
      Const conquery As String = "Events_Clients Query_Select_1"
    On Error GoTo HandleErrors
    ' Delete the rtf file, if it already exists.
    strPath = FixPath(CurrentProject.Path)
    strDataSource = strPath & conquery & ".doc"
    Kill strDataSource
   
    ' Export the data to rtf format
    DoCmd.OutputTo acOutputQuery, conquery, _
     acFormatRTF, strDataSource, False

    ' Start Word using mailmerge template
    Set wrdApp = New Word.Application
    Set doc = wrdApp.Documents.Add(strPath & contemplate)

The path is set correctly and I tried to set it as a string to the correct path, I get the same results...

Could it be a timing issue, because it might take some time to access the host. - maybe a security problem, in thai case, why is  the call "strDataSource = strPath & conquery & ".doc"" successful?
Thanks
Josh
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question