Solved

Export Access to Word template

Posted on 2008-10-29
3
1,384 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

738 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