My first question to you is, exactly what is the source of the list items? Is it
a NotesPage for a specific slide, such as
ActivePresentation.Slides(1).NotesPage? And what property of the NotesPage
object do you address to get the strings of the tags?
In the userform, you need a list box plus an OK button. The default names of
these controls are ListBox1 and CommandButton1 (although you're encouraged to
change them to names that reflect their usages).
In the Userform_Initialize procedure of the userform (which executes just before
the userform is displayed), place code that opens the PPT presentation and then
iterates through the strings in the appropriate NotesPage object. For each
string, call the ListBox1.AddItem method to insert the string into the list
box's list. It's also a good idea to set ListBox1.ListIndex = 0 to ensure that
there is always some value selected (the default is .ListIndex = -1, which
doesn't select any value).
In the CommandButton1_Click procedure (which executes when the user clicks the
OK button), place code that hides the userform (Me.Hide). This causes control to
return to the macro that called the userform.
To call the userform onto the screen, your macro should do something like this:
Sub Demo()
Dim myVar As Variable
Dim testVar As Variable
Dim UF As UserForm1
Const varName = "foo"
Set UF = New UserForm1
UF.Show
With ActiveDocument
' check for doc variable
For Each testVar In .Variables
If LCase(testVar.Name) = LCase(varName) Then
Set myVar = testVar
Exit For
End If
Next
If myVar Is Nothing Then ' need to add it
.Variables.Add Name:=varName, _
Value:=UF.ListBox1.Value
Else ' already exists
.Variables(varName).Value = _
UF.ListBox1.Value
End If
' add DocVariable field
.Fields.Add _
Range:=ActiveDocument.Bookmarks("XXYY").Range, _
Type:=wdFieldEmpty, _
Text:="DOCVARIABLE " & varName
' update
.Fields.Update
End With
' release memory
Set UF = Nothing
End Sub
Thanks for the link. I think what's described there doesn't apply to my need,
but I'll give more detail.
[quoted text clipped - 24 lines]
--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.