Very strange Word behaviour...

perlfan

Registered User.
Local time
Today, 14:51
Joined
May 26, 2009
Messages
192
Hi - I'm getting a very strange File not found message.
I have set up my Access FE in a way that users can use an Access BE database or a MySQL database. To create quotes/invoices I pass data to Word - this works perfectly using the filepath stored in the MySQL database. With the Access database Word gives me a File not found error message at Run MacroName:=
Without running the macro it will open without any problems:
Code:
Set wordApp = New Word.Application
            With wordApp
                .Documents.Open filename:=strFileName
                .Application.Run MacroName:="fill_with_data"
                .Visible = True
                .Activate
            End With
Again - the code works perfectly when strFileName is stored in MySQL. Am I missing something obvious here? Thanks for help!
 
Where are you adding value to strFileName and how does the value looks like?
 
In Access I do write into a temporary txt file that I read with the Word macro.
But it never gets to Word because the code is interrupted in Access.
BTW: It's a docm file and I didn't want to use an auto excec macro because the file is a template.
 
I think you misunderstood my question! :)
Where in your code are you adding value to variable strFileName?
How does the value you added looks like, (ex. C:\....)?
 
Sorry!

Code:
Dim strFileName As String
Set db = CurrentDb              
     strSql = "Select company_information.quote_template from company_information INNER JOIN (customers INNER JOIN quotes ON customers.CustomerID = quotes.CustomerID) ON company_information.ID = customers.ResponsibleCompany WHERE quotes.QuoteID= " & req_quoteID & ""
     Set rs = db.OpenRecordset(strSql) 
     Template = rs!quote_template
strFileName = Template

The path is: C:\XY\templates\Quote template.docm
When I comment out the run macro line, the file opens without problems.
 
Sorry - I just reread your post #1, what does the macro "fill_with_data", how does the code looks like?
Can't you set in a break/stop point in the macro, to see in which line/where the error appear?
 
Solved! Thank you - I thought that the Word macro would not be executed at all but it was. Then I saw that I was not linking to the Access db correctly and the path to the temp txt file was not given at all for the Access db version (only when MySQL was used). Thanks! FRANK
 
You're welcome - luck with your project! :)
 

Users who are viewing this thread

Back
Top Bottom