Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Esseaemme Esseaemme is offline
external usenet poster
 
Posts: 1
Default How to use macro with 2 different template for transition mail mer



Problem : I need to use a macro that work with two different template because
of a mail merge.

Hello,

Ive my macro in offer_crm.dot. It works this way:
a) If the document has not been saved it save the doc with protocol name.
b) If the document has been saved, it rename the document and save the doc
and it refresh the protocol version

When i print from CRM the offer for a customer and I use the offer_crm.dot
template. With my macro i save the document with its protocol number. But
the problem is when I reopen the offer, it ask me for the option of mail
merge.

At this point then:
1) Print from CRM offert with template offer_crm.dot
2) I do mail merge, and it create a new document from template normal.dot

I want to create a macro that make:
1) From my offer with template offer_crm.dot it does a mail merge
2) Now there is a new offert with template normal.dot and it save the document

The problem is I want to have one only macro that make all this for me.
But when I do mail merge, the macro stop itself and it say its not there
anymore.
At this point: .Destination = wdSendToNewDocument

Is there any way to have only one macro that works in two different template?

My code is:

Sub CRM()

Const conPercorso As String = "c:\offerte"
Dim rTMp As Range
Dim vTMp As Range
Dim protNewVersion As String
Dim strNameFile As String
Dim strControllo As String
Dim prot As String

strNameFile = ActiveDocument.Name
strControllo = Mid(strNameFile, 1, 5)

If strControllo = "Docum" Then
With ActiveDocument.MailMerge
..Destination = wdSendToNewDocument
..SuppressBlankLines = True
With .DataSource
..FirstRecord = wdDefaultFirstRecord
..LastRecord = wdDefaultLastRecord
End With
..Execute Pause:=False
End With



With ActiveWindow.View
..ShowRevisionsAndComments = False
..RevisionsView = wdRevisionsViewFinal
End With

ActiveDocument.MailMerge.ViewMailMergeFieldCodes = wdToggle
CommandBars("Task Pane").Visible = False

Set rTMp = Selection.Paragraphs(1).Range

If rTMp.Characters(1) = "x" Then
rTMp.Start = rTMp.Start + 1
rTMp.End = rTMp.End - 1
rTMp.Select
MsgBox rTMp
prot = rTMp
ChangeFileOpenDirectory conPercorso
ActiveDocument.SaveAs FileName:=prot
Else
MsgBox "Non c'è il numero di protocollo e non è stato
salvato il documento"
End If
Else

With ActiveWindow.View
..ShowRevisionsAndComments = False
..RevisionsView = wdRevisionsViewFinal
End With
protNewVersion = Mid(strNameFile, 1, 17)
ChangeFileOpenDirectory conPercorso
ActiveDocument.SaveAs FileName:=protNewVersion

With Selection
..HomeKey Unit:=wdStory
..MoveDown Unit:=wdLine, Count:=1
..MoveRight Unit:=wdCharacter, Count:=11
..MoveRight Unit:=wdCharacter, Count:=17, Extend:=wdExtend
..TypeText protNewVersion
End With
MsgBox "Il file è stato salvato con il nome del protocollo e il nr. di
protocollo è stato aggiornato"

End If

End Sub


Thanks a lot for any suggestions,
Best Regards,
Samantha
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Cindy M. Cindy M. is offline
external usenet poster
 
Posts: 2,416
Default How to use macro with 2 different template for transition mail mer

Hi Samantha,

I'm not certain I'm understanding exactly what you have, and what you need. But
it might help if you first could tell us the version of Word involved?

Problem : I need to use a macro that work with two different template because
of a mail merge.

Hello,

Ive my macro in offer_crm.dot. It works this way:
a) If the document has not been saved it save the doc with protocol name.
b) If the document has been saved, it rename the document and save the doc
and it refresh the protocol version

When i print from CRM the offer for a customer and I use the offer_crm.dot
template. With my macro i save the document with its protocol number. But
the problem is when I reopen the offer, it ask me for the option of mail
merge.

At this point then:
1) Print from CRM offert with template offer_crm.dot
2) I do mail merge, and it create a new document from template normal.dot

I want to create a macro that make:
1) From my offer with template offer_crm.dot it does a mail merge
2) Now there is a new offert with template normal.dot and it save the document

The problem is I want to have one only macro that make all this for me.
But when I do mail merge, the macro stop itself and it say its not there
anymore.
At this point: .Destination = wdSendToNewDocument

Is there any way to have only one macro that works in two different template?

My code is:

Sub CRM()

Const conPercorso As String = "c:\offerte"
Dim rTMp As Range
Dim vTMp As Range
Dim protNewVersion As String
Dim strNameFile As String
Dim strControllo As String
Dim prot As String

strNameFile = ActiveDocument.Name
strControllo = Mid(strNameFile, 1, 5)

If strControllo = "Docum" Then
With ActiveDocument.MailMerge
..Destination = wdSendToNewDocument
..SuppressBlankLines = True
With .DataSource
..FirstRecord = wdDefaultFirstRecord
..LastRecord = wdDefaultLastRecord
End With
..Execute Pause:=False
End With



With ActiveWindow.View
..ShowRevisionsAndComments = False
..RevisionsView = wdRevisionsViewFinal
End With

ActiveDocument.MailMerge.ViewMailMergeFieldCodes = wdToggle
CommandBars("Task Pane").Visible = False

Set rTMp = Selection.Paragraphs(1).Range

If rTMp.Characters(1) = "x" Then
rTMp.Start = rTMp.Start + 1
rTMp.End = rTMp.End - 1
rTMp.Select
MsgBox rTMp
prot = rTMp
ChangeFileOpenDirectory conPercorso
ActiveDocument.SaveAs FileName:=prot
Else
MsgBox "Non c'è il numero di protocollo e non è stato
salvato il documento"
End If
Else

With ActiveWindow.View
..ShowRevisionsAndComments = False
..RevisionsView = wdRevisionsViewFinal
End With
protNewVersion = Mid(strNameFile, 1, 17)
ChangeFileOpenDirectory conPercorso
ActiveDocument.SaveAs FileName:=protNewVersion

With Selection
..HomeKey Unit:=wdStory
..MoveDown Unit:=wdLine, Count:=1
..MoveRight Unit:=wdCharacter, Count:=11
..MoveRight Unit:=wdCharacter, Count:=17, Extend:=wdExtend
..TypeText protNewVersion
End With
MsgBox "Il file è stato salvato con il nome del protocollo e il nr. di
protocollo è stato aggiornato"

End If

End Sub


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)

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
Mail merge in Word from Outlook Catagories stephen Mailmerge 7 December 11th 06 06:48 PM
How do you use a template? TheWheel Microsoft Word Help 10 August 25th 06 04:34 PM
FilePrint macro didn't work after all... janice Microsoft Word Help 11 March 28th 06 06:26 PM
Modifying a macro in a global template Bob S New Users 4 March 14th 05 05:43 PM
Moving templates to other computer GeorgeMar Microsoft Word Help 10 February 19th 05 04:59 AM


All times are GMT +1. The time now is 08:48 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"