View Full Version : Need the Word 2010 vba equivalent of merge command
Hello all,
I need the word 2010 vba equivalent of this type of command:
[code]
'preRRPolicies$ = preRRPolicies$ + WordBasic.[GetMergeField$]("Pre_RR_Contracts_for_Addressee")
p/code]
What does the plus sign do?
Any and all help is greatly appreciated!
Kurt:dunno
Can someone tell me what the plus sign does? I think it is trying to add a field and I am researching the syntax in word 2010 vba. I really need some help on this thanks!
I am trying this but I get red meaning an error of course:
pensionPolicies$ = ActiveDocument.MailMerge.Fields.Add, Range:=Selection.Range,"pensionPolicies"
Am I on the right track here?
I found this while doing a search in Word 2010 on Add Field which is what I think the plus sign does.
With ActiveDocument
.Variables.Add Name:="pensionPolicies$"
.Fields.Add Range:=Selection.Range, Type:=wdFieldDocVariable, Text:="pensionPolicies"
End With
Anyone wiht anything would be greatly appreciated!
EdHunter
11-27-2012, 02:09 PM
Don't know if this is what your after but the VBA to execute a mail merge is:
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
Ed,
Thanks for the try, but I don't think that is it.
Can someone please tell me what the + sign does and its' equivlaent in Word 2010?
Thanks,
Kurt
fumei
11-27-2012, 03:35 PM
The plus sign is the same as the ampersand (&). It concatenates two strings together. It is a Basic term and has nothing specific to do with 2010.
"yadda" + "blah"
is the same as
"yadda" & "blah"
BOTH = "yaddablah"
Now it MAY be true that in 2010 VBA no longer recognizes that + and & are the same. I do not know. But in WordBasic (old,old, old) the plus sign was commonly used. Certainly up to 2003 VBA did not care if you used + or &, it was happy with both, or either.
Yep you are correct!
I just got off the phone with someone who said the same thing.
I got it figured out and you just double confirmed it!
Am I correct in assuming it is looking for the valuable of the variable in the string with the $ ?
fumei
11-27-2012, 03:49 PM
'preRRPolicies$ = preRRPolicies$ + WordBasic.[GetMergeField$]("Pre_RR_Contracts_for_Addressee")
means
The string variable preRRPolicies equals the string variable preRRPolicies with the string value of the merge field Pre_RR_Contracts_for_Addressee added to the end.
So if preRRPolicies = "yadda", and Pre_RR_Contracts_for_Addressee = "blah"
preRRPolicies now = "yaddablah"
macropod
11-27-2012, 04:21 PM
Cross-posted at: http://www.msofficeforums.com/word-vba/15226-word-2007-word-2010-vba-syntax.html
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
So is this the correct way to do this in word vba 2010?
pensionPolicies = pensionPolicies & ActiveDocument.MailMerge.DataSource.DataFields("pensionPolicies").Value
fumei
11-27-2012, 06:47 PM
Since I have no idea what pensionPolicies is, it is hard to say, but it looks like it should be fine.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.