Hello Tek-Tippers!
LTNS!
My golf club (like most, if not all, other golf clubs) runs monthly competitions called 'Monthly Medals'. This competition is open for entry over three days, usually the Friday, Saturday, and Sunday of the second full weekend of the month (so 7th-9th at the earliest, 14th to 16th at the latest).
The Saturday of the this competition weekend is the official day, with the Friday and Sunday designated as 'Alternate' days. Sometimes (rarely) the course is closed on a Friday so we move that alternate day to the Monday (but this is rare enough that we can deal with it manually as and when required).
Each member can only play in the competition once, and to declare this they have to sign in on a sheet before they tee off (if they play on the Friday and have a bad round, or they get rained off, it's tough luck, they can't play on a different day to submit a second scorecard).
So, every month we open a Word (2016) template to create a PDF of the sign in sheet to supply to the pro shop to print off and place on the board. This sheet has three pages, one page for each day. Each page states the following information which changes (or potentially can change) every month:
[ul]
[li]The name of the competition (e.g. "Men's January 2020 Monthly Medal")[/li]
[li]The date for each day[/li]
[li]Whether it's a Handicap Qualifier (this is a boolean)[/li]
[li]The scoring format (essentially another boolean as there are only two choices: Stableford and Strokeplay)[/li]
[li]The tees to be used[/li]
[li]Are Winter Rules in use (another boolean)[/li]
[/ul]
Here's an example screenshot (with some added highlights):
Up until now we've manually changed the various parts (usually with Find Replace), but sometimes the human factor gets involved, for instance supplying a PDF that stated the wrong scoring format, or that winter rules were in operation in August!
I've been playing around with Content Controls, which can be nice, but still require the operator to manually change the value of each one. Not cool. What I'd prefer is to run a VBA macro to prompt the operator for each bit of information as per the bullet list above.
Clearly we only want to enter one date (once) then let differently formatted bookmarks display either the Month and Year, or the day, or the full date as required, adding a day on page two, then another day on page three (page 3 not shown in the screenshot example).
So far I've got this code:
But this approach of adding then deleting document variables seems very clunky. Also I've not yet considered how to get the date from the operator. A DatePicker would be nice but I'm not yet convinced VBA is up to that (likely that I'm wrong though).
So, all a bit big and vague. Sorry, but still, what are your thoughts?
Urgency level is low.
JJ
[small][purple]Variables won't. Constants aren't[/purple]
There is no apostrophe in the plural of PC (or PST, or CPU, or HDD, or FDD, or photo, or breakfast...and so on)[/small]
LTNS!
My golf club (like most, if not all, other golf clubs) runs monthly competitions called 'Monthly Medals'. This competition is open for entry over three days, usually the Friday, Saturday, and Sunday of the second full weekend of the month (so 7th-9th at the earliest, 14th to 16th at the latest).
The Saturday of the this competition weekend is the official day, with the Friday and Sunday designated as 'Alternate' days. Sometimes (rarely) the course is closed on a Friday so we move that alternate day to the Monday (but this is rare enough that we can deal with it manually as and when required).
Each member can only play in the competition once, and to declare this they have to sign in on a sheet before they tee off (if they play on the Friday and have a bad round, or they get rained off, it's tough luck, they can't play on a different day to submit a second scorecard).
So, every month we open a Word (2016) template to create a PDF of the sign in sheet to supply to the pro shop to print off and place on the board. This sheet has three pages, one page for each day. Each page states the following information which changes (or potentially can change) every month:
[ul]
[li]The name of the competition (e.g. "Men's January 2020 Monthly Medal")[/li]
[li]The date for each day[/li]
[li]Whether it's a Handicap Qualifier (this is a boolean)[/li]
[li]The scoring format (essentially another boolean as there are only two choices: Stableford and Strokeplay)[/li]
[li]The tees to be used[/li]
[li]Are Winter Rules in use (another boolean)[/li]
[/ul]
Here's an example screenshot (with some added highlights):

Up until now we've manually changed the various parts (usually with Find Replace), but sometimes the human factor gets involved, for instance supplying a PDF that stated the wrong scoring format, or that winter rules were in operation in August!
I've been playing around with Content Controls, which can be nice, but still require the operator to manually change the value of each one. Not cool. What I'd prefer is to run a VBA macro to prompt the operator for each bit of information as per the bullet list above.
Clearly we only want to enter one date (once) then let differently formatted bookmarks display either the Month and Year, or the day, or the full date as required, adding a day on page two, then another day on page three (page 3 not shown in the screenshot example).
So far I've got this code:
Code:
Sub SetDocVars()
On Error Resume Next
strScoringFormat = "Strokeplay / Stableford"
strTee = "All tee shots must be taken from the white teeing areas. Use the white markers if available AND in usual white tee box, otherwise UP TO five club lengths forward of the white plates."
strWinterRules = "Winter Rules (preferred lies on closely mown grass)"
strScoringFormat = InputBox("Which scoring format is to be played (delete as appropriate)?", "Scoring Format", strScoringFormat)
strTee = InputBox("Which tees are to be used?", "Tees", strTee)
ActiveDocument.Variables.Add Name:="ScoringFormat", Value:=strScoringFormat
ActiveDocument.Variables.Add Name:="StartDate", Value:=dtStartDate
ActiveDocument.Variables.Add Name:="HandicapQualifier", Value:=bHandicapQualifier
ActiveDocument.Variables.Add Name:="Tee", Value:=strTee
ActiveDocument.Variables.Add Name:="WinterRules", Value:=bWinterRules
' Select everything to update the fields (because Microsoft still assume everything is printed so only auto-update fields at print time)
Dim myRange
Set myRange = Selection.Range
Selection.WholeStory
Selection.Fields.Update
myRange.Select
' Delete the variable.
ActiveDocument.Variables("ScoringFormat").Delete
ActiveDocument.Variables("StartDate").Delete
ActiveDocument.Variables("HandicapQualifier").Delete
ActiveDocument.Variables("Tee").Delete
End Sub
But this approach of adding then deleting document variables seems very clunky. Also I've not yet considered how to get the date from the operator. A DatePicker would be nice but I'm not yet convinced VBA is up to that (likely that I'm wrong though).
So, all a bit big and vague. Sorry, but still, what are your thoughts?
Urgency level is low.
JJ
[small][purple]Variables won't. Constants aren't[/purple]
There is no apostrophe in the plural of PC (or PST, or CPU, or HDD, or FDD, or photo, or breakfast...and so on)[/small]