Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
.ActiveDocument.mailmerge Syntax sometimes not working
Hello, I'm using this code below from with Access to open a Word document.
It works fine on my machine but I have a user that gets an error when trying to run the mailmerge.execute line. Any thought why? Dim objApp As Object Dim strDocName As String Dim strDocNameB As String 'strDocName = rs!ClosingDir & "\MasterTest.doc" strDocName = rs!ClosingDir & "\" & rs!ClosingDoc Set objApp = CreateObject("Word.application") With objApp .Visible = True .Documents.Open strDocName strDocNameB = objApp.ActiveDocument.Name ***Lines Below sometimes don't work on other machines. .ActiveDocument.mailmerge.Destination = 0 'wdSendToNewDocument .ActiveDocument.mailmerge.Execute .Documents(strDocNameB).Close 0 End With |
#2
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
.ActiveDocument.mailmerge Syntax sometimes not working
An attempt to set .Destination will fail if there is no data source. Since
there is no OpenDataSource method call in the code you have posted, my guess is that you have attached the word document to a data source, then closed it. That's fine, unless Word cannot re-attach the document to the source when it re-opens the document, and that could happen for various reasons, e.g. the data source is not where Word expects to find it, or some users are using a different Word version or Service Pack from others. Ther are a couple of things you could try to find out what is gong on: a. add error trapping to your Access code, if you haven't already b. ask 1 user whose system works and 1 user whose system doesn't to open the datasource manually, and see what happens. Peter Jamieson "Don" wrote in message ... Hello, I'm using this code below from with Access to open a Word document. It works fine on my machine but I have a user that gets an error when trying to run the mailmerge.execute line. Any thought why? Dim objApp As Object Dim strDocName As String Dim strDocNameB As String 'strDocName = rs!ClosingDir & "\MasterTest.doc" strDocName = rs!ClosingDir & "\" & rs!ClosingDoc Set objApp = CreateObject("Word.application") With objApp .Visible = True .Documents.Open strDocName strDocNameB = objApp.ActiveDocument.Name ***Lines Below sometimes don't work on other machines. .ActiveDocument.mailmerge.Destination = 0 'wdSendToNewDocument .ActiveDocument.mailmerge.Execute .Documents(strDocNameB).Close 0 End With |
#3
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
.ActiveDocument.mailmerge Syntax sometimes not working
The main document is linking correctly to the text file that I have it set
to. I have looked at the main document(mailmerge document) and the values are being pulled from the text file. I just get an error message when trying to execute it into a new document. "Peter Jamieson" wrote: An attempt to set .Destination will fail if there is no data source. Since there is no OpenDataSource method call in the code you have posted, my guess is that you have attached the word document to a data source, then closed it. That's fine, unless Word cannot re-attach the document to the source when it re-opens the document, and that could happen for various reasons, e.g. the data source is not where Word expects to find it, or some users are using a different Word version or Service Pack from others. Ther are a couple of things you could try to find out what is gong on: a. add error trapping to your Access code, if you haven't already b. ask 1 user whose system works and 1 user whose system doesn't to open the datasource manually, and see what happens. Peter Jamieson "Don" wrote in message ... Hello, I'm using this code below from with Access to open a Word document. It works fine on my machine but I have a user that gets an error when trying to run the mailmerge.execute line. Any thought why? Dim objApp As Object Dim strDocName As String Dim strDocNameB As String 'strDocName = rs!ClosingDir & "\MasterTest.doc" strDocName = rs!ClosingDir & "\" & rs!ClosingDoc Set objApp = CreateObject("Word.application") With objApp .Visible = True .Documents.Open strDocName strDocNameB = objApp.ActiveDocument.Name ***Lines Below sometimes don't work on other machines. .ActiveDocument.mailmerge.Destination = 0 'wdSendToNewDocument .ActiveDocument.mailmerge.Execute .Documents(strDocNameB).Close 0 End With |
#4
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
.ActiveDocument.mailmerge Syntax sometimes not working
OK, so it never fails at the point when you set the destination. In that
case nothing springs to mind, but does it fail if you set the Destination to be 1 (Send to printer) ? If not, then I suppose I would start looking for some reason why Word could not open a temporary document, e.g. perhaps there is a security-related issue on some machines. ( This is probably nothing to do with the problem but I wouldn't use ActiveDocument in case something else was being opened for some reason, and would use something more like... Dim objApp As Object DIm objDoc As Object ' or As Word.Document Dim strDocName As String 'Dim strDocNameB As String 'strDocName = rs!ClosingDir & "\MasterTest.doc" strDocName = rs!ClosingDir & "\" & rs!ClosingDoc Set objApp = CreateObject("Word.application") objApp.Visible = True set objDoc = objApp.Documents.Open strDocName 'strDocNameB = objDoc.Name objDoc.mailmerge.Destination = 0 'wdSendToNewDocument objDoc.mailmerge.Execute objDoc.Close 0 set objDoc = Nothing ) Peter Jamieson "Don" wrote in message ... The main document is linking correctly to the text file that I have it set to. I have looked at the main document(mailmerge document) and the values are being pulled from the text file. I just get an error message when trying to execute it into a new document. "Peter Jamieson" wrote: An attempt to set .Destination will fail if there is no data source. Since there is no OpenDataSource method call in the code you have posted, my guess is that you have attached the word document to a data source, then closed it. That's fine, unless Word cannot re-attach the document to the source when it re-opens the document, and that could happen for various reasons, e.g. the data source is not where Word expects to find it, or some users are using a different Word version or Service Pack from others. Ther are a couple of things you could try to find out what is gong on: a. add error trapping to your Access code, if you haven't already b. ask 1 user whose system works and 1 user whose system doesn't to open the datasource manually, and see what happens. Peter Jamieson "Don" wrote in message ... Hello, I'm using this code below from with Access to open a Word document. It works fine on my machine but I have a user that gets an error when trying to run the mailmerge.execute line. Any thought why? Dim objApp As Object Dim strDocName As String Dim strDocNameB As String 'strDocName = rs!ClosingDir & "\MasterTest.doc" strDocName = rs!ClosingDir & "\" & rs!ClosingDoc Set objApp = CreateObject("Word.application") With objApp .Visible = True .Documents.Open strDocName strDocNameB = objApp.ActiveDocument.Name ***Lines Below sometimes don't work on other machines. .ActiveDocument.mailmerge.Destination = 0 'wdSendToNewDocument .ActiveDocument.mailmerge.Execute .Documents(strDocNameB).Close 0 End With |
#5
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
.ActiveDocument.mailmerge Syntax sometimes not working
Thanks for the help, this is an issue when using Word 2003.
Seems like the security on Word 2003 drops the linked datasource when opened so I did have to reset the datasource to the text file I use. ActiveDocument.MailMerge.OpenDataSource "Path&FileName" "Peter Jamieson" wrote: OK, so it never fails at the point when you set the destination. In that case nothing springs to mind, but does it fail if you set the Destination to be 1 (Send to printer) ? If not, then I suppose I would start looking for some reason why Word could not open a temporary document, e.g. perhaps there is a security-related issue on some machines. ( This is probably nothing to do with the problem but I wouldn't use ActiveDocument in case something else was being opened for some reason, and would use something more like... Dim objApp As Object DIm objDoc As Object ' or As Word.Document Dim strDocName As String 'Dim strDocNameB As String 'strDocName = rs!ClosingDir & "\MasterTest.doc" strDocName = rs!ClosingDir & "\" & rs!ClosingDoc Set objApp = CreateObject("Word.application") objApp.Visible = True set objDoc = objApp.Documents.Open strDocName 'strDocNameB = objDoc.Name objDoc.mailmerge.Destination = 0 'wdSendToNewDocument objDoc.mailmerge.Execute objDoc.Close 0 set objDoc = Nothing ) Peter Jamieson "Don" wrote in message ... The main document is linking correctly to the text file that I have it set to. I have looked at the main document(mailmerge document) and the values are being pulled from the text file. I just get an error message when trying to execute it into a new document. "Peter Jamieson" wrote: An attempt to set .Destination will fail if there is no data source. Since there is no OpenDataSource method call in the code you have posted, my guess is that you have attached the word document to a data source, then closed it. That's fine, unless Word cannot re-attach the document to the source when it re-opens the document, and that could happen for various reasons, e.g. the data source is not where Word expects to find it, or some users are using a different Word version or Service Pack from others. Ther are a couple of things you could try to find out what is gong on: a. add error trapping to your Access code, if you haven't already b. ask 1 user whose system works and 1 user whose system doesn't to open the datasource manually, and see what happens. Peter Jamieson "Don" wrote in message ... Hello, I'm using this code below from with Access to open a Word document. It works fine on my machine but I have a user that gets an error when trying to run the mailmerge.execute line. Any thought why? Dim objApp As Object Dim strDocName As String Dim strDocNameB As String 'strDocName = rs!ClosingDir & "\MasterTest.doc" strDocName = rs!ClosingDir & "\" & rs!ClosingDoc Set objApp = CreateObject("Word.application") With objApp .Visible = True .Documents.Open strDocName strDocNameB = objApp.ActiveDocument.Name ***Lines Below sometimes don't work on other machines. .ActiveDocument.mailmerge.Destination = 0 'wdSendToNewDocument .ActiveDocument.mailmerge.Execute .Documents(strDocNameB).Close 0 End With |
#6
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
.ActiveDocument.mailmerge Syntax sometimes not working
If you solved it, fine, but if not,
1. when Word 2003 (and Word XP with recent SPs) tries to connect to a data source, it typically pops up a dialog about executing some SQL. If the user accepts, the connection is made (all other things being equal), otherwise the connection fails/ 2. When the document is loaded programatically, you may find that the connection is always failed. For further info. on that, see the following article "Opening This Will Run the Following SQL Command" Message When You Open a Word Document" at http://support.microsoft.com?kbid=825765 Peter Jamieson "Don" wrote in message ... Thanks for the help, this is an issue when using Word 2003. Seems like the security on Word 2003 drops the linked datasource when opened so I did have to reset the datasource to the text file I use. ActiveDocument.MailMerge.OpenDataSource "Path&FileName" "Peter Jamieson" wrote: OK, so it never fails at the point when you set the destination. In that case nothing springs to mind, but does it fail if you set the Destination to be 1 (Send to printer) ? If not, then I suppose I would start looking for some reason why Word could not open a temporary document, e.g. perhaps there is a security-related issue on some machines. ( This is probably nothing to do with the problem but I wouldn't use ActiveDocument in case something else was being opened for some reason, and would use something more like... Dim objApp As Object DIm objDoc As Object ' or As Word.Document Dim strDocName As String 'Dim strDocNameB As String 'strDocName = rs!ClosingDir & "\MasterTest.doc" strDocName = rs!ClosingDir & "\" & rs!ClosingDoc Set objApp = CreateObject("Word.application") objApp.Visible = True set objDoc = objApp.Documents.Open strDocName 'strDocNameB = objDoc.Name objDoc.mailmerge.Destination = 0 'wdSendToNewDocument objDoc.mailmerge.Execute objDoc.Close 0 set objDoc = Nothing ) Peter Jamieson "Don" wrote in message ... The main document is linking correctly to the text file that I have it set to. I have looked at the main document(mailmerge document) and the values are being pulled from the text file. I just get an error message when trying to execute it into a new document. "Peter Jamieson" wrote: An attempt to set .Destination will fail if there is no data source. Since there is no OpenDataSource method call in the code you have posted, my guess is that you have attached the word document to a data source, then closed it. That's fine, unless Word cannot re-attach the document to the source when it re-opens the document, and that could happen for various reasons, e.g. the data source is not where Word expects to find it, or some users are using a different Word version or Service Pack from others. Ther are a couple of things you could try to find out what is gong on: a. add error trapping to your Access code, if you haven't already b. ask 1 user whose system works and 1 user whose system doesn't to open the datasource manually, and see what happens. Peter Jamieson "Don" wrote in message ... Hello, I'm using this code below from with Access to open a Word document. It works fine on my machine but I have a user that gets an error when trying to run the mailmerge.execute line. Any thought why? Dim objApp As Object Dim strDocName As String Dim strDocNameB As String 'strDocName = rs!ClosingDir & "\MasterTest.doc" strDocName = rs!ClosingDir & "\" & rs!ClosingDoc Set objApp = CreateObject("Word.application") With objApp .Visible = True .Documents.Open strDocName strDocNameB = objApp.ActiveDocument.Name ***Lines Below sometimes don't work on other machines. .ActiveDocument.mailmerge.Destination = 0 'wdSendToNewDocument .ActiveDocument.mailmerge.Execute .Documents(strDocNameB).Close 0 End With |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
delete not working | Microsoft Word Help | |||
Working with large Word documents with embedded Excel diagrams | Microsoft Word Help | |||
CPU Usage When working with a Template I Created | Microsoft Word Help | |||
CPU Usage When Working with Templates you created | Microsoft Word Help | |||
Syntax for Number format in the Text Form Field Options | Microsoft Word Help |