Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
I sometimes only need to print one envelope from my mail merge list. Thanks
to Peter Jamieson who a wrote who a while ago wrote the following macro for me which allows me to select a starting letter for the merge. I was wondering if the macro (I have a hard time spelling macro) could be edited so that if I inserted a telephone number only that record would pop up in the envelope. Sub OneMergePerInitialLetterAskStart() ' error trapping to be added Dim bDone As Boolean Dim iLetter As Integer Dim objMMMD As Word.Document Dim strColumnName As String Dim strSheetName As String Dim strStartLetter As String bDone = False Do strStartLetter = InputBox("Enter the starting letter," & _ " or blank to quit", "Starting letter", "a") strStartLetter = UCase(Trim(strStartLetter)) If Len(strStartLetter) = 0 Then bDone = True Else If Len(strStartLetter) 1 Then MsgBox "Enter a single letter" & _ " (from A to Z or a to z)," & _ " or blank to quit", vbOKOnly Else If strStartLetter "A" _ Or strStartLetter "Z" Then MsgBox "Enter a (single) letter" & _ " from A to Z or a to z," & _ " or blank to quit", vbOKOnly Else bDone = True End If End If End If Loop Until bDone If strStartLetter "" Then ' Set this to the name of the worksheet or to the range name strSheetName = "Nominal Roll$" ' Set this to the exact name of the column containing the name ' (upper/lower case is probably significant strColumnName = "LastName" Set objMMMD = ActiveDocument With objMMMD For iLetter = Asc(strStartLetter) To Asc("Z") .MailMerge.DataSource.QueryString = _ " SELECT * FROM [" & strSheetName & "]" & _ " WHERE ucase(" & strColumnName & ") like '" & _ Chr(iLetter) & "%'" With .MailMerge ' remove or change this as necessary .Destination = wdSendToNewDocument On Error GoTo norecords .Execute Pause:=False End With If MsgBox("Completed Letter " & Chr(iLetter) & _ ". Do the next letter?", vbOKCancel) = vbCancel Then Exit For End If norecords: If Err.Number = 5631 Then ' Assume it is because there were no records for this letter ' Not necessarily true - could be just a badly formed query Err.Clear On Error GoTo 0 Resume atloop Else ' just stop On Error GoTo 0 End If atloop: Next End With Set objMMMD = Nothing End If End Sub -- Regards Michael Koerner |
#2
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
Can the phone number only appear in one column in your data source, or
could it be in several? Do your numbers have non-numeric characters, e.g. extension numbers introduced with "x", international "+" at the beginning of the number, spaces, etc.? Peter Jamieson http://tips.pjmsn.me.uk Visit Londinium at http://www.ralphwatson.tv Michael Koerner wrote: I sometimes only need to print one envelope from my mail merge list. Thanks to Peter Jamieson who a wrote who a while ago wrote the following macro for me which allows me to select a starting letter for the merge. I was wondering if the macro (I have a hard time spelling macro) could be edited so that if I inserted a telephone number only that record would pop up in the envelope. Sub OneMergePerInitialLetterAskStart() ' error trapping to be added Dim bDone As Boolean Dim iLetter As Integer Dim objMMMD As Word.Document Dim strColumnName As String Dim strSheetName As String Dim strStartLetter As String bDone = False Do strStartLetter = InputBox("Enter the starting letter," & _ " or blank to quit", "Starting letter", "a") strStartLetter = UCase(Trim(strStartLetter)) If Len(strStartLetter) = 0 Then bDone = True Else If Len(strStartLetter) 1 Then MsgBox "Enter a single letter" & _ " (from A to Z or a to z)," & _ " or blank to quit", vbOKOnly Else If strStartLetter "A" _ Or strStartLetter "Z" Then MsgBox "Enter a (single) letter" & _ " from A to Z or a to z," & _ " or blank to quit", vbOKOnly Else bDone = True End If End If End If Loop Until bDone If strStartLetter "" Then ' Set this to the name of the worksheet or to the range name strSheetName = "Nominal Roll$" ' Set this to the exact name of the column containing the name ' (upper/lower case is probably significant strColumnName = "LastName" Set objMMMD = ActiveDocument With objMMMD For iLetter = Asc(strStartLetter) To Asc("Z") .MailMerge.DataSource.QueryString = _ " SELECT * FROM [" & strSheetName & "]" & _ " WHERE ucase(" & strColumnName & ") like '" & _ Chr(iLetter) & "%'" With .MailMerge ' remove or change this as necessary .Destination = wdSendToNewDocument On Error GoTo norecords .Execute Pause:=False End With If MsgBox("Completed Letter " & Chr(iLetter) & _ ". Do the next letter?", vbOKCancel) = vbCancel Then Exit For End If norecords: If Err.Number = 5631 Then ' Assume it is because there were no records for this letter ' Not necessarily true - could be just a badly formed query Err.Clear On Error GoTo 0 Resume atloop Else ' just stop On Error GoTo 0 End If atloop: Next End With Set objMMMD = Nothing End If End Sub |
#3
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
Peter;
The phone number is only in one data source which is in this case is Excel Col " O" with a header row called PhoneNumber and appear as xxx-xxx-xxxx -- Regards Michael Koerner "Peter Jamieson" wrote in message ... Can the phone number only appear in one column in your data source, or could it be in several? Do your numbers have non-numeric characters, e.g. extension numbers introduced with "x", international "+" at the beginning of the number, spaces, etc.? Peter Jamieson http://tips.pjmsn.me.uk Visit Londinium at http://www.ralphwatson.tv Michael Koerner wrote: I sometimes only need to print one envelope from my mail merge list. Thanks to Peter Jamieson who a wrote who a while ago wrote the following macro for me which allows me to select a starting letter for the merge. I was wondering if the macro (I have a hard time spelling macro) could be edited so that if I inserted a telephone number only that record would pop up in the envelope. Sub OneMergePerInitialLetterAskStart() ' error trapping to be added Dim bDone As Boolean Dim iLetter As Integer Dim objMMMD As Word.Document Dim strColumnName As String Dim strSheetName As String Dim strStartLetter As String bDone = False Do strStartLetter = InputBox("Enter the starting letter," & _ " or blank to quit", "Starting letter", "a") strStartLetter = UCase(Trim(strStartLetter)) If Len(strStartLetter) = 0 Then bDone = True Else If Len(strStartLetter) 1 Then MsgBox "Enter a single letter" & _ " (from A to Z or a to z)," & _ " or blank to quit", vbOKOnly Else If strStartLetter "A" _ Or strStartLetter "Z" Then MsgBox "Enter a (single) letter" & _ " from A to Z or a to z," & _ " or blank to quit", vbOKOnly Else bDone = True End If End If End If Loop Until bDone If strStartLetter "" Then ' Set this to the name of the worksheet or to the range name strSheetName = "Nominal Roll$" ' Set this to the exact name of the column containing the name ' (upper/lower case is probably significant strColumnName = "LastName" Set objMMMD = ActiveDocument With objMMMD For iLetter = Asc(strStartLetter) To Asc("Z") .MailMerge.DataSource.QueryString = _ " SELECT * FROM [" & strSheetName & "]" & _ " WHERE ucase(" & strColumnName & ") like '" & _ Chr(iLetter) & "%'" With .MailMerge ' remove or change this as necessary .Destination = wdSendToNewDocument On Error GoTo norecords .Execute Pause:=False End With If MsgBox("Completed Letter " & Chr(iLetter) & _ ". Do the next letter?", vbOKCancel) = vbCancel Then Exit For End If norecords: If Err.Number = 5631 Then ' Assume it is because there were no records for this letter ' Not necessarily true - could be just a badly formed query Err.Clear On Error GoTo 0 Resume atloop Else ' just stop On Error GoTo 0 End If atloop: Next End With Set objMMMD = Nothing End If End Sub |
#4
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
Peter;
I could introduce a 5 digit (xxxxx) record number in Col A if that would make things easier. That way it would cover any international addresses that may pop up in the future. -- Regards Michael Koerner "Peter Jamieson" wrote in message ... Can the phone number only appear in one column in your data source, or could it be in several? Do your numbers have non-numeric characters, e.g. extension numbers introduced with "x", international "+" at the beginning of the number, spaces, etc.? Peter Jamieson http://tips.pjmsn.me.uk Visit Londinium at http://www.ralphwatson.tv Michael Koerner wrote: I sometimes only need to print one envelope from my mail merge list. Thanks to Peter Jamieson who a wrote who a while ago wrote the following macro for me which allows me to select a starting letter for the merge. I was wondering if the macro (I have a hard time spelling macro) could be edited so that if I inserted a telephone number only that record would pop up in the envelope. Sub OneMergePerInitialLetterAskStart() ' error trapping to be added Dim bDone As Boolean Dim iLetter As Integer Dim objMMMD As Word.Document Dim strColumnName As String Dim strSheetName As String Dim strStartLetter As String bDone = False Do strStartLetter = InputBox("Enter the starting letter," & _ " or blank to quit", "Starting letter", "a") strStartLetter = UCase(Trim(strStartLetter)) If Len(strStartLetter) = 0 Then bDone = True Else If Len(strStartLetter) 1 Then MsgBox "Enter a single letter" & _ " (from A to Z or a to z)," & _ " or blank to quit", vbOKOnly Else If strStartLetter "A" _ Or strStartLetter "Z" Then MsgBox "Enter a (single) letter" & _ " from A to Z or a to z," & _ " or blank to quit", vbOKOnly Else bDone = True End If End If End If Loop Until bDone If strStartLetter "" Then ' Set this to the name of the worksheet or to the range name strSheetName = "Nominal Roll$" ' Set this to the exact name of the column containing the name ' (upper/lower case is probably significant strColumnName = "LastName" Set objMMMD = ActiveDocument With objMMMD For iLetter = Asc(strStartLetter) To Asc("Z") .MailMerge.DataSource.QueryString = _ " SELECT * FROM [" & strSheetName & "]" & _ " WHERE ucase(" & strColumnName & ") like '" & _ Chr(iLetter) & "%'" With .MailMerge ' remove or change this as necessary .Destination = wdSendToNewDocument On Error GoTo norecords .Execute Pause:=False End With If MsgBox("Completed Letter " & Chr(iLetter) & _ ". Do the next letter?", vbOKCancel) = vbCancel Then Exit For End If norecords: If Err.Number = 5631 Then ' Assume it is because there were no records for this letter ' Not necessarily true - could be just a badly formed query Err.Clear On Error GoTo 0 Resume atloop Else ' just stop On Error GoTo 0 End If atloop: Next End With Set objMMMD = Nothing End If End Sub |
#5
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
Plus a 5 digit number is easier to insert than a 10 digit telephone number
g -- Regards Michael Koerner "Michael Koerner" wrote in message ... Peter; I could introduce a 5 digit (xxxxx) record number in Col A if that would make things easier. That way it would cover any international addresses that may pop up in the future. -- Regards Michael Koerner "Peter Jamieson" wrote in message ... Can the phone number only appear in one column in your data source, or could it be in several? Do your numbers have non-numeric characters, e.g. extension numbers introduced with "x", international "+" at the beginning of the number, spaces, etc.? Peter Jamieson http://tips.pjmsn.me.uk Visit Londinium at http://www.ralphwatson.tv Michael Koerner wrote: I sometimes only need to print one envelope from my mail merge list. Thanks to Peter Jamieson who a wrote who a while ago wrote the following macro for me which allows me to select a starting letter for the merge. I was wondering if the macro (I have a hard time spelling macro) could be edited so that if I inserted a telephone number only that record would pop up in the envelope. Sub OneMergePerInitialLetterAskStart() ' error trapping to be added Dim bDone As Boolean Dim iLetter As Integer Dim objMMMD As Word.Document Dim strColumnName As String Dim strSheetName As String Dim strStartLetter As String bDone = False Do strStartLetter = InputBox("Enter the starting letter," & _ " or blank to quit", "Starting letter", "a") strStartLetter = UCase(Trim(strStartLetter)) If Len(strStartLetter) = 0 Then bDone = True Else If Len(strStartLetter) 1 Then MsgBox "Enter a single letter" & _ " (from A to Z or a to z)," & _ " or blank to quit", vbOKOnly Else If strStartLetter "A" _ Or strStartLetter "Z" Then MsgBox "Enter a (single) letter" & _ " from A to Z or a to z," & _ " or blank to quit", vbOKOnly Else bDone = True End If End If End If Loop Until bDone If strStartLetter "" Then ' Set this to the name of the worksheet or to the range name strSheetName = "Nominal Roll$" ' Set this to the exact name of the column containing the name ' (upper/lower case is probably significant strColumnName = "LastName" Set objMMMD = ActiveDocument With objMMMD For iLetter = Asc(strStartLetter) To Asc("Z") .MailMerge.DataSource.QueryString = _ " SELECT * FROM [" & strSheetName & "]" & _ " WHERE ucase(" & strColumnName & ") like '" & _ Chr(iLetter) & "%'" With .MailMerge ' remove or change this as necessary .Destination = wdSendToNewDocument On Error GoTo norecords .Execute Pause:=False End With If MsgBox("Completed Letter " & Chr(iLetter) & _ ". Do the next letter?", vbOKCancel) = vbCancel Then Exit For End If norecords: If Err.Number = 5631 Then ' Assume it is because there were no records for this letter ' Not necessarily true - could be just a badly formed query Err.Clear On Error GoTo 0 Resume atloop Else ' just stop On Error GoTo 0 End If atloop: Next End With Set objMMMD = Nothing End If End Sub |
#6
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
See how you get on with this (it's a completely separate process from
the last one) FWIW I try to keep the amount of "coding to order" I do to an absolute minimum. This is more than I've done for some time. Sub SelectPhoneNumberAndMerge() ' error trapping to be added Dim bDone As Boolean Dim objMMMD As Word.Document Dim strColumnName As String Dim lngCount As Long Dim strSheetName As String Dim strPhoneNumber As String bDone = False strPhoneNumber = "" Do strPhoneNumber = InputBox("Enter the phone number -" & _ " only use 0-9, '-' and '+'," & _ " or blank to quit", _ "Phone number", strStartLetter) strPhoneNumber = Replace(UCase(Trim(strPhoneNumber)), " ", "") If Len(strPhoneNumber) = 0 Then bDone = True Else If invalidPhoneNumber(strPhoneNumber) Then MsgBox "Don't put anything except 0-9," & _ "'-' and '+' in the phone number", _ vbOKOnly Else ' Set this to the name of the worksheet or to the range name strSheetName = "Nominal Roll$" ' Set this to the exact name of the column containing the phone number ' (upper/lower case is probably significant strColumnName = "PhoneNumber" Set objMMMD = ActiveDocument With objMMMD.MailMerge ' I would like to use count(*) to get the ' record count but cannot make it work .DataSource.QueryString = _ " SELECT *" & _ " FROM [" & strSheetName & "]" & _ " WHERE " & CStr(strColumnName) & " like '" & _ strPhoneNumber & "%'" .DataSource.ActiveRecord = wdLastRecord lngCount = .DataSource.ActiveRecord End With Set objMMMD = Nothing Select Case lngCount Case 0 MsgBox "No records matched the number you entered", vbOKOnly Case 1 ' OK bDone = True Case Else MsgBox "More than 1 record matched the number you entered", vbOKOnly End Select End If End If Loop Until bDone If strPhoneNumber "" Then Set objMMMD = ActiveDocument With objMMMD.MailMerge ' remove or change this as necessary .Destination = wdSendToNewDocument .Execute Pause:=False End With Set objMMMD = Nothing End If End Sub Function invalidPhoneNumber(ByRef strPhone As String) As Boolean ' Shouldn't really return a parameter ' using byref in a function but ' there you go Dim c As Long Dim s As String s = "" invalidPhoneNumber = False For c = 1 To Len(strPhone) Select Case Mid(strPhone, c, 1) Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "-" s = s & Mid(strPhone, c, 1) Case Else invalidPhoneNumber = True End Select Next strPhone = s End Function Peter Jamieson http://tips.pjmsn.me.uk Visit Londinium at http://www.ralphwatson.tv Michael Koerner wrote: Peter; The phone number is only in one data source which is in this case is Excel Col " O" with a header row called PhoneNumber and appear as xxx-xxx-xxxx |
#7
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
Peter;
After correcting a couple word wraps from the cut and paste, I'm on bended knees to you. Thank you very much, it works like a charm. Now all I need is someone to help me get up off my knees. g -- Regards Michael Koerner "Peter Jamieson" wrote in message ... See how you get on with this (it's a completely separate process from the last one) FWIW I try to keep the amount of "coding to order" I do to an absolute minimum. This is more than I've done for some time. Sub SelectPhoneNumberAndMerge() ' error trapping to be added Dim bDone As Boolean Dim objMMMD As Word.Document Dim strColumnName As String Dim lngCount As Long Dim strSheetName As String Dim strPhoneNumber As String bDone = False strPhoneNumber = "" Do strPhoneNumber = InputBox("Enter the phone number -" & _ " only use 0-9, '-' and '+'," & _ " or blank to quit", _ "Phone number", strStartLetter) strPhoneNumber = Replace(UCase(Trim(strPhoneNumber)), " ", "") If Len(strPhoneNumber) = 0 Then bDone = True Else If invalidPhoneNumber(strPhoneNumber) Then MsgBox "Don't put anything except 0-9," & _ "'-' and '+' in the phone number", _ vbOKOnly Else ' Set this to the name of the worksheet or to the range name strSheetName = "Nominal Roll$" ' Set this to the exact name of the column containing the phone number ' (upper/lower case is probably significant strColumnName = "PhoneNumber" Set objMMMD = ActiveDocument With objMMMD.MailMerge ' I would like to use count(*) to get the ' record count but cannot make it work .DataSource.QueryString = _ " SELECT *" & _ " FROM [" & strSheetName & "]" & _ " WHERE " & CStr(strColumnName) & " like '" & _ strPhoneNumber & "%'" .DataSource.ActiveRecord = wdLastRecord lngCount = .DataSource.ActiveRecord End With Set objMMMD = Nothing Select Case lngCount Case 0 MsgBox "No records matched the number you entered", vbOKOnly Case 1 ' OK bDone = True Case Else MsgBox "More than 1 record matched the number you entered", vbOKOnly End Select End If End If Loop Until bDone If strPhoneNumber "" Then Set objMMMD = ActiveDocument With objMMMD.MailMerge ' remove or change this as necessary .Destination = wdSendToNewDocument .Execute Pause:=False End With Set objMMMD = Nothing End If End Sub Function invalidPhoneNumber(ByRef strPhone As String) As Boolean ' Shouldn't really return a parameter ' using byref in a function but ' there you go Dim c As Long Dim s As String s = "" invalidPhoneNumber = False For c = 1 To Len(strPhone) Select Case Mid(strPhone, c, 1) Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "-" s = s & Mid(strPhone, c, 1) Case Else invalidPhoneNumber = True End Select Next strPhone = s End Function Peter Jamieson http://tips.pjmsn.me.uk Visit Londinium at http://www.ralphwatson.tv Michael Koerner wrote: Peter; The phone number is only in one data source which is in this case is Excel Col " O" with a header row called PhoneNumber and appear as xxx-xxx-xxxx |
#8
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
It's OK Michael, you can get up now :-))
Seriously, glad it works. Peter Jamieson http://tips.pjmsn.me.uk Visit Londinium at http://www.ralphwatson.tv Michael Koerner wrote: Peter; After correcting a couple word wraps from the cut and paste, I'm on bended knees to you. Thank you very much, it works like a charm. Now all I need is someone to help me get up off my knees. g |
#9
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
Peter I was a little quick to answer. I ran it again, and received the
following VB Compile Error "Ambiguous name detected: invalidPhoneNumber" and the following opens up as highlighted Function invalidPhoneNumber(ByRef strPhone As String) As Boolean -- Regards Michael Koerner "Peter Jamieson" wrote in message ... See how you get on with this (it's a completely separate process from the last one) FWIW I try to keep the amount of "coding to order" I do to an absolute minimum. This is more than I've done for some time. Sub SelectPhoneNumberAndMerge() ' error trapping to be added Dim bDone As Boolean Dim objMMMD As Word.Document Dim strColumnName As String Dim lngCount As Long Dim strSheetName As String Dim strPhoneNumber As String bDone = False strPhoneNumber = "" Do strPhoneNumber = InputBox("Enter the phone number -" & _ " only use 0-9, '-' and '+'," & _ " or blank to quit", _ "Phone number", strStartLetter) strPhoneNumber = Replace(UCase(Trim(strPhoneNumber)), " ", "") If Len(strPhoneNumber) = 0 Then bDone = True Else If invalidPhoneNumber(strPhoneNumber) Then MsgBox "Don't put anything except 0-9," & _ "'-' and '+' in the phone number", _ vbOKOnly Else ' Set this to the name of the worksheet or to the range name strSheetName = "Nominal Roll$" ' Set this to the exact name of the column containing the phone number ' (upper/lower case is probably significant strColumnName = "PhoneNumber" Set objMMMD = ActiveDocument With objMMMD.MailMerge ' I would like to use count(*) to get the ' record count but cannot make it work .DataSource.QueryString = _ " SELECT *" & _ " FROM [" & strSheetName & "]" & _ " WHERE " & CStr(strColumnName) & " like '" & _ strPhoneNumber & "%'" .DataSource.ActiveRecord = wdLastRecord lngCount = .DataSource.ActiveRecord End With Set objMMMD = Nothing Select Case lngCount Case 0 MsgBox "No records matched the number you entered", vbOKOnly Case 1 ' OK bDone = True Case Else MsgBox "More than 1 record matched the number you entered", vbOKOnly End Select End If End If Loop Until bDone If strPhoneNumber "" Then Set objMMMD = ActiveDocument With objMMMD.MailMerge ' remove or change this as necessary .Destination = wdSendToNewDocument .Execute Pause:=False End With Set objMMMD = Nothing End If End Sub Function invalidPhoneNumber(ByRef strPhone As String) As Boolean ' Shouldn't really return a parameter ' using byref in a function but ' there you go Dim c As Long Dim s As String s = "" invalidPhoneNumber = False For c = 1 To Len(strPhone) Select Case Mid(strPhone, c, 1) Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "-" s = s & Mid(strPhone, c, 1) Case Else invalidPhoneNumber = True End Select Next strPhone = s End Function Peter Jamieson http://tips.pjmsn.me.uk Visit Londinium at http://www.ralphwatson.tv Michael Koerner wrote: Peter; The phone number is only in one data source which is in this case is Excel Col " O" with a header row called PhoneNumber and appear as xxx-xxx-xxxx |
#10
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
I suspected it was too good to be true!
I don't suppose you have copied/pasted the macro into more than one place, e.g. into a macro in the document, and a macro in the normal template or an attached template? FWIW, when faced with this kind of stuff I tend to a. ensure that the active document is the one I intended it to be. After you've run it once, the active document is often something else, e.g. the output document from the previous merge. (probably wouldn't cause this particular error though) b. close Word, preferably make sure it's dead, start Word again, open your mail merge main document, try again. Peter Jamieson http://tips.pjmsn.me.uk Visit Londinium at http://www.ralphwatson.tv Michael Koerner wrote: Peter I was a little quick to answer. I ran it again, and received the following VB Compile Error "Ambiguous name detected: invalidPhoneNumber" and the following opens up as highlighted Function invalidPhoneNumber(ByRef strPhone As String) As Boolean |
#11
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
I looked, and it saved it as a docm file instead of a dotx. It works only I
get a macro alert message at the beginning where I have to allow the macro to run. -- Regards Michael Koerner "Peter Jamieson" wrote in message ... I suspected it was too good to be true! I don't suppose you have copied/pasted the macro into more than one place, e.g. into a macro in the document, and a macro in the normal template or an attached template? FWIW, when faced with this kind of stuff I tend to a. ensure that the active document is the one I intended it to be. After you've run it once, the active document is often something else, e.g. the output document from the previous merge. (probably wouldn't cause this particular error though) b. close Word, preferably make sure it's dead, start Word again, open your mail merge main document, try again. Peter Jamieson http://tips.pjmsn.me.uk Visit Londinium at http://www.ralphwatson.tv Michael Koerner wrote: Peter I was a little quick to answer. I ran it again, and received the following VB Compile Error "Ambiguous name detected: invalidPhoneNumber" and the following opens up as highlighted Function invalidPhoneNumber(ByRef strPhone As String) As Boolean |
#12
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
You may be able to get rid of those by modifying the settings in Word
Office Button-Word OptionsTrust Center-Trust Center Settings, then -Macro Settings and/or Trusted Locations. Peter Jamieson http://tips.pjmsn.me.uk Visit Londinium at http://www.ralphwatson.tv Michael Koerner wrote: I looked, and it saved it as a docm file instead of a dotx. It works only I get a macro alert message at the beginning where I have to allow the macro to run. |
#13
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
Understood, as long as I allow all macros. Thanks
-- Regards Michael Koerner "Peter Jamieson" wrote in message ... You may be able to get rid of those by modifying the settings in Word Office Button-Word OptionsTrust Center-Trust Center Settings, then -Macro Settings and/or Trusted Locations. Peter Jamieson http://tips.pjmsn.me.uk Visit Londinium at http://www.ralphwatson.tv Michael Koerner wrote: I looked, and it saved it as a docm file instead of a dotx. It works only I get a macro alert message at the beginning where I have to allow the macro to run. |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Selecting Multiple Recipients for merge | Mailmerge | |||
selecting records to merge | Mailmerge | |||
sort mail merge by merge record number | Mailmerge | |||
Merge files keep selecting their own fields. How to fix? | Mailmerge | |||
label merge only 1st record is merging-rest of source won't merge | Mailmerge |