save mail merge document without saving macro

K

Karin

I am running a mail merge macro that sends the merged document to a new
document. I then do a save as to save the new document. The problem is that
it is also saving the macro with the new document. How can I save the new
document without the macro in it?
Thanks for your help.
Karin
 
D

Doug Robbins - Word MVP

Save your mailmerge main document as a template and use File>New and select
that template as the basis of the mail merge main document that you want to
use, then execute the mail merge from that new document.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
K

Karin

My VBA code is in a .dot document. In the code I am saying:
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute pause:=True
End With
Sorry, I am not sure how to change it to do what you are suggesting.
 
D

Doug Robbins - Word MVP

Is the .dot document the mail merge main document?

How are you creating the ActiveDocument?

What else does your code do? There is no reason to use a macro to do just
what the code that you posted does.
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
K

Karin

Yes, the .dot document is the mail merge main document. I want to do a mail
merge to a new document, print the new document, save the new document
without the macro and close all documents. This is the entire code:

Private Sub Document_New()
' open letter document

On Error GoTo Err_New
ActiveDocument.MailMerge.OpenDataSource Name:="", ConfirmConversions:= _
False, ReadOnly:=False, linktosource:=True, addtorecentfiles:=False, _
passworddocument:="", passwordtemplate:="", writepassworddocument:="", _
writepasswordtemplate:="", revert:=False, Format:=wdOpenFormatAuto, _
connection:="DSN=SchoolTRAX;DATABASE=SDGStudent;" _
, sqlstatement:= _
"SELECT * FROM [STUDENT_S_LETTER_FETCH]", sqlstatement1:=""

Dim doc1, doc2
Set doc1 = ActiveDocument
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute pause:=True
End With
Set doc2 = ActiveDocument
ActiveDocument.SaveAs ("C:\Program Files\SD&G
Ltd\SchoolTRAX\Reports\TempReport.doc")
ActiveDocument.PrintOut
ActiveDocument.Close
doc1.Close wdDoNotSaveChanges

Exit_New:
Exit Sub
Err_New:
If Err.Number <> 0 And Err.Number <> 4198 Then
msg = "error # " & Str(Err.Number) & "was generated by " _
& Err.Source & Chr(13) & Err.Description
MsgBox msg, , "error", Err.HelpFile, Err.HelpContext
Debug.Print Error(Err.Number)
End If
Resume Exit_New
End Sub

Thanks.
Karin
 
D

Doug Robbins - Word MVP

And how do you get the mail merge main document on the screen? By using
File>Open, or File>New? You should use the latter.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
Karin said:
Yes, the .dot document is the mail merge main document. I want to do a
mail
merge to a new document, print the new document, save the new document
without the macro and close all documents. This is the entire code:

Private Sub Document_New()
' open letter document

On Error GoTo Err_New
ActiveDocument.MailMerge.OpenDataSource Name:="", ConfirmConversions:=
_
False, ReadOnly:=False, linktosource:=True, addtorecentfiles:=False, _
passworddocument:="", passwordtemplate:="", writepassworddocument:="",
_
writepasswordtemplate:="", revert:=False, Format:=wdOpenFormatAuto, _
connection:="DSN=SchoolTRAX;DATABASE=SDGStudent;" _
, sqlstatement:= _
"SELECT * FROM [STUDENT_S_LETTER_FETCH]", sqlstatement1:=""

Dim doc1, doc2
Set doc1 = ActiveDocument
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute pause:=True
End With
Set doc2 = ActiveDocument
ActiveDocument.SaveAs ("C:\Program Files\SD&G
Ltd\SchoolTRAX\Reports\TempReport.doc")
ActiveDocument.PrintOut
ActiveDocument.Close
doc1.Close wdDoNotSaveChanges

Exit_New:
Exit Sub
Err_New:
If Err.Number <> 0 And Err.Number <> 4198 Then
msg = "error # " & Str(Err.Number) & "was generated by " _
& Err.Source & Chr(13) & Err.Description
MsgBox msg, , "error", Err.HelpFile, Err.HelpContext
Debug.Print Error(Err.Number)
End If
Resume Exit_New
End Sub

Thanks.
Karin

Doug Robbins - Word MVP said:
Is the .dot document the mail merge main document?

How are you creating the ActiveDocument?

What else does your code do? There is no reason to use a macro to do
just
what the code that you posted does.
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
K

Karin

I am using vbscript, which is doing a file open the main document (.dot
file). If I do a file new how do I get the mail merge to run? The macro is in
the the .dot file not the new document. Do I need vbscript to open a new
document using the mail merge main document as a template?

Doug Robbins - Word MVP said:
And how do you get the mail merge main document on the screen? By using
File>Open, or File>New? You should use the latter.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
Karin said:
Yes, the .dot document is the mail merge main document. I want to do a
mail
merge to a new document, print the new document, save the new document
without the macro and close all documents. This is the entire code:

Private Sub Document_New()
' open letter document

On Error GoTo Err_New
ActiveDocument.MailMerge.OpenDataSource Name:="", ConfirmConversions:=
_
False, ReadOnly:=False, linktosource:=True, addtorecentfiles:=False, _
passworddocument:="", passwordtemplate:="", writepassworddocument:="",
_
writepasswordtemplate:="", revert:=False, Format:=wdOpenFormatAuto, _
connection:="DSN=SchoolTRAX;DATABASE=SDGStudent;" _
, sqlstatement:= _
"SELECT * FROM [STUDENT_S_LETTER_FETCH]", sqlstatement1:=""

Dim doc1, doc2
Set doc1 = ActiveDocument
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute pause:=True
End With
Set doc2 = ActiveDocument
ActiveDocument.SaveAs ("C:\Program Files\SD&G
Ltd\SchoolTRAX\Reports\TempReport.doc")
ActiveDocument.PrintOut
ActiveDocument.Close
doc1.Close wdDoNotSaveChanges

Exit_New:
Exit Sub
Err_New:
If Err.Number <> 0 And Err.Number <> 4198 Then
msg = "error # " & Str(Err.Number) & "was generated by " _
& Err.Source & Chr(13) & Err.Description
MsgBox msg, , "error", Err.HelpFile, Err.HelpContext
Debug.Print Error(Err.Number)
End If
Resume Exit_New
End Sub

Thanks.
Karin

Doug Robbins - Word MVP said:
Is the .dot document the mail merge main document?

How are you creating the ActiveDocument?

What else does your code do? There is no reason to use a macro to do
just
what the code that you posted does.
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
My VBA code is in a .dot document. In the code I am saying:
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute pause:=True
End With
Sorry, I am not sure how to change it to do what you are suggesting.

:

Save your mailmerge main document as a template and use File>New and
select
that template as the basis of the mail merge main document that you
want
to
use, then execute the mail merge from that new document.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
I am running a mail merge macro that sends the merged document to a
new
document. I then do a save as to save the new document. The problem
is
that
it is also saving the macro with the new document. How can I save
the
new
document without the macro in it?
Thanks for your help.
Karin
 
D

Doug Robbins - Word MVP

Macros that are in a template are available to a document that is created
from that template (on the same machine).
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
Karin said:
I am using vbscript, which is doing a file open the main document (.dot
file). If I do a file new how do I get the mail merge to run? The macro is
in
the the .dot file not the new document. Do I need vbscript to open a new
document using the mail merge main document as a template?

Doug Robbins - Word MVP said:
And how do you get the mail merge main document on the screen? By using
File>Open, or File>New? You should use the latter.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
Karin said:
Yes, the .dot document is the mail merge main document. I want to do a
mail
merge to a new document, print the new document, save the new document
without the macro and close all documents. This is the entire code:

Private Sub Document_New()
' open letter document

On Error GoTo Err_New
ActiveDocument.MailMerge.OpenDataSource Name:="",
ConfirmConversions:=
_
False, ReadOnly:=False, linktosource:=True, addtorecentfiles:=False,
_
passworddocument:="", passwordtemplate:="",
writepassworddocument:="",
_
writepasswordtemplate:="", revert:=False, Format:=wdOpenFormatAuto,
_
connection:="DSN=SchoolTRAX;DATABASE=SDGStudent;" _
, sqlstatement:= _
"SELECT * FROM [STUDENT_S_LETTER_FETCH]", sqlstatement1:=""

Dim doc1, doc2
Set doc1 = ActiveDocument
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute pause:=True
End With
Set doc2 = ActiveDocument
ActiveDocument.SaveAs ("C:\Program Files\SD&G
Ltd\SchoolTRAX\Reports\TempReport.doc")
ActiveDocument.PrintOut
ActiveDocument.Close
doc1.Close wdDoNotSaveChanges

Exit_New:
Exit Sub
Err_New:
If Err.Number <> 0 And Err.Number <> 4198 Then
msg = "error # " & Str(Err.Number) & "was generated by " _
& Err.Source & Chr(13) & Err.Description
MsgBox msg, , "error", Err.HelpFile, Err.HelpContext
Debug.Print Error(Err.Number)
End If
Resume Exit_New
End Sub

Thanks.
Karin

:

Is the .dot document the mail merge main document?

How are you creating the ActiveDocument?

What else does your code do? There is no reason to use a macro to do
just
what the code that you posted does.
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
My VBA code is in a .dot document. In the code I am saying:
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute pause:=True
End With
Sorry, I am not sure how to change it to do what you are suggesting.

:

Save your mailmerge main document as a template and use File>New
and
select
that template as the basis of the mail merge main document that you
want
to
use, then execute the mail merge from that new document.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of
my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
I am running a mail merge macro that sends the merged document to
a
new
document. I then do a save as to save the new document. The
problem
is
that
it is also saving the macro with the new document. How can I save
the
new
document without the macro in it?
Thanks for your help.
Karin
 
K

Karin

I need help with the vbscript to open a new document using the template. Can
you help me or do I need to go the the vbscript forum?
Thanks.

Doug Robbins - Word MVP said:
Macros that are in a template are available to a document that is created
from that template (on the same machine).
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
Karin said:
I am using vbscript, which is doing a file open the main document (.dot
file). If I do a file new how do I get the mail merge to run? The macro is
in
the the .dot file not the new document. Do I need vbscript to open a new
document using the mail merge main document as a template?

Doug Robbins - Word MVP said:
And how do you get the mail merge main document on the screen? By using
File>Open, or File>New? You should use the latter.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
Yes, the .dot document is the mail merge main document. I want to do a
mail
merge to a new document, print the new document, save the new document
without the macro and close all documents. This is the entire code:

Private Sub Document_New()
' open letter document

On Error GoTo Err_New
ActiveDocument.MailMerge.OpenDataSource Name:="",
ConfirmConversions:=
_
False, ReadOnly:=False, linktosource:=True, addtorecentfiles:=False,
_
passworddocument:="", passwordtemplate:="",
writepassworddocument:="",
_
writepasswordtemplate:="", revert:=False, Format:=wdOpenFormatAuto,
_
connection:="DSN=SchoolTRAX;DATABASE=SDGStudent;" _
, sqlstatement:= _
"SELECT * FROM [STUDENT_S_LETTER_FETCH]", sqlstatement1:=""

Dim doc1, doc2
Set doc1 = ActiveDocument
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute pause:=True
End With
Set doc2 = ActiveDocument
ActiveDocument.SaveAs ("C:\Program Files\SD&G
Ltd\SchoolTRAX\Reports\TempReport.doc")
ActiveDocument.PrintOut
ActiveDocument.Close
doc1.Close wdDoNotSaveChanges

Exit_New:
Exit Sub
Err_New:
If Err.Number <> 0 And Err.Number <> 4198 Then
msg = "error # " & Str(Err.Number) & "was generated by " _
& Err.Source & Chr(13) & Err.Description
MsgBox msg, , "error", Err.HelpFile, Err.HelpContext
Debug.Print Error(Err.Number)
End If
Resume Exit_New
End Sub

Thanks.
Karin

:

Is the .dot document the mail merge main document?

How are you creating the ActiveDocument?

What else does your code do? There is no reason to use a macro to do
just
what the code that you posted does.
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
My VBA code is in a .dot document. In the code I am saying:
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute pause:=True
End With
Sorry, I am not sure how to change it to do what you are suggesting.

:

Save your mailmerge main document as a template and use File>New
and
select
that template as the basis of the mail merge main document that you
want
to
use, then execute the mail merge from that new document.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of
my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
I am running a mail merge macro that sends the merged document to
a
new
document. I then do a save as to save the new document. The
problem
is
that
it is also saving the macro with the new document. How can I save
the
new
document without the macro in it?
Thanks for your help.
Karin
 
K

Karin

Using Vbscript to open a new document using a template gives me an error. So
I found a way around it by copying and pasting the document with the mail
merge template into a new document which uses the normal template.
Thanks for all your help.
Karin
 
D

Doug Robbins - Word MVP

In Visual Basic, you would use

Dim MailMergeMainDoc as Document
Set MailMergeMainDoc = Documents.Add("Path\TemplateName.dot(m)")

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
Karin said:
I need help with the vbscript to open a new document using the template.
Can
you help me or do I need to go the the vbscript forum?
Thanks.

Doug Robbins - Word MVP said:
Macros that are in a template are available to a document that is created
from that template (on the same machine).
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
Karin said:
I am using vbscript, which is doing a file open the main document (.dot
file). If I do a file new how do I get the mail merge to run? The macro
is
in
the the .dot file not the new document. Do I need vbscript to open a
new
document using the mail merge main document as a template?

:

And how do you get the mail merge main document on the screen? By
using
File>Open, or File>New? You should use the latter.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
Yes, the .dot document is the mail merge main document. I want to do
a
mail
merge to a new document, print the new document, save the new
document
without the macro and close all documents. This is the entire code:

Private Sub Document_New()
' open letter document

On Error GoTo Err_New
ActiveDocument.MailMerge.OpenDataSource Name:="",
ConfirmConversions:=
_
False, ReadOnly:=False, linktosource:=True,
addtorecentfiles:=False,
_
passworddocument:="", passwordtemplate:="",
writepassworddocument:="",
_
writepasswordtemplate:="", revert:=False,
Format:=wdOpenFormatAuto,
_
connection:="DSN=SchoolTRAX;DATABASE=SDGStudent;" _
, sqlstatement:= _
"SELECT * FROM [STUDENT_S_LETTER_FETCH]", sqlstatement1:=""

Dim doc1, doc2
Set doc1 = ActiveDocument
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute pause:=True
End With
Set doc2 = ActiveDocument
ActiveDocument.SaveAs ("C:\Program Files\SD&G
Ltd\SchoolTRAX\Reports\TempReport.doc")
ActiveDocument.PrintOut
ActiveDocument.Close
doc1.Close wdDoNotSaveChanges

Exit_New:
Exit Sub
Err_New:
If Err.Number <> 0 And Err.Number <> 4198 Then
msg = "error # " & Str(Err.Number) & "was generated by " _
& Err.Source & Chr(13) & Err.Description
MsgBox msg, , "error", Err.HelpFile, Err.HelpContext
Debug.Print Error(Err.Number)
End If
Resume Exit_New
End Sub

Thanks.
Karin

:

Is the .dot document the mail merge main document?

How are you creating the ActiveDocument?

What else does your code do? There is no reason to use a macro to
do
just
what the code that you posted does.
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of
my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
My VBA code is in a .dot document. In the code I am saying:
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute pause:=True
End With
Sorry, I am not sure how to change it to do what you are
suggesting.

:

Save your mailmerge main document as a template and use File>New
and
select
that template as the basis of the mail merge main document that
you
want
to
use, then execute the mail merge from that new document.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself
of
my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via
msnews.microsoft.com
I am running a mail merge macro that sends the merged document
to
a
new
document. I then do a save as to save the new document. The
problem
is
that
it is also saving the macro with the new document. How can I
save
the
new
document without the macro in it?
Thanks for your help.
Karin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top