Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I have four variables that are set on load of the document called:
vPrevWeekEndingDate
vPrevWeekEndingDate2
vPrevWeekEndingDate3
vPrevWeekEndingDate4
These basically hold the last four week ending dates.
Within a macro I then need to apply these dates to the selection list I have for WeekEnding Dates.
When setting a single value I have used the below code which has worked perfectly:
ActiveDocument.Fields("WeekEnding").Select getVariable("vPrevWeekEndingDate")
However I am not sure of the syntax to set all four values into the list. I have tried the following but it doesn't work:
ActiveDocument.Fields("WeekEnding").Select("( getVariable(vPrevWeekEndingDate)|getVariable(vPrevWeekEndingDate)|getVariable(vPrevWeekEndingDate)|getVariable(vPrevWeekEndingDate))")
I am sure it is something to do with the quotes because I had to take the quotes out from around each variable otherwise I get an error on checking but without the quotes I don't get anything selected?
Can anyone help with the required syntax to do this please?
Many thanks
Ben
Hi
Try like this
sub CurrentSelection
set f=ActiveDocument.GetField("[WeekEnding]")
set v1 = ActiveDocument.Variables("vPrevWeekEndingDate2")
set v2 =ActiveDocument.Variables("vPrevWeekEndingDat3")
set v3 =ActiveDocument.Variables("vPrevWeekEndingDate4")
set v4 =ActiveDocument.Variables("vPrevWeekEndingDate")
v5 = "(" & v1.GetContent.String & "|" & v2.GetContent.String & "|" & v3.GetContent.String &"|" & v4.GetContent.String &")"
msgbox v5
f.select v5
end sub
HI
Why you refer macro rather than trigger selection?
Hi
Try like this
sub CurrentSelection
set f=ActiveDocument.GetField("[WeekEnding]")
set v1 = ActiveDocument.Variables("vPrevWeekEndingDate2")
set v2 =ActiveDocument.Variables("vPrevWeekEndingDat3")
set v3 =ActiveDocument.Variables("vPrevWeekEndingDate4")
set v4 =ActiveDocument.Variables("vPrevWeekEndingDate")
v5 = "(" & v1.GetContent.String & "|" & v2.GetContent.String & "|" & v3.GetContent.String &"|" & v4.GetContent.String &")"
msgbox v5
f.select v5
end sub
Hi Mayil,
Thanks for the reply, I need to use a macro to set the values as it is all part of a macro that runs a report and e-mails the report out.
I tried your code but it still fails where it is setting v5
Thanks
Ben
Hi Again Mayil,
Sorry I jumped the gun and have just realised there was a typo in your code (vPrevWeekEndingDat3 was missing the e!) so now I have corrected that it is working great.
Thanks so much for your time and assistance with this one.
Regards
Ben