Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Don
 
Posts: n/a
Default .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   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
 
Posts: n/a
Default .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   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Don
 
Posts: n/a
Default .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   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
 
Posts: n/a
Default .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   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Don
 
Posts: n/a
Default .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   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
 
Posts: n/a
Default .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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
delete not working steve Microsoft Word Help 2 October 11th 07 10:03 PM
Working with large Word documents with embedded Excel diagrams carlos de Noruega Microsoft Word Help 3 October 19th 05 12:10 PM
CPU Usage When working with a Template I Created KM1 Microsoft Word Help 6 May 24th 05 04:38 PM
CPU Usage When Working with Templates you created KM1 Microsoft Word Help 3 May 21st 05 11:57 PM
Syntax for Number format in the Text Form Field Options Ed Hall 61 Microsoft Word Help 3 May 8th 05 07:51 PM


All times are GMT +1. The time now is 12:39 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"