?
Solved

Export Access to Word template

Posted on 2008-10-29
3
Medium Priority
?
1,395 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

743 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