Hello Guru's!
I have given myself a crash course in vba programming by trying to make a word document with a drop down menu that has several different outputs
for example if you selected "N" in the drop down menu it would populate several different fields throughout the document
I have the drop down menu run the macro below on exit and at this point ive used the { email } field directly in the document and it states "Error bookmark not defined"
How do I output values from the macro into the word document?
thank you in advance for taking the time to point me in the right direction
code below:
Sub stest()
Dim servicearea As String
Dim Email As String
Dim phone As String
Email = "1@m.org"
phone = ("8-- --- ----")
Select Case servicearea
Case "N":
Selection.TypeText Email = ("2@m.org")
Selection.TypeText phone = ("8-- --- ----")
nextcase:
Case "S":
Selection.TypeText Email = ("3@m.org")
Selection.TypeText phone = ("8-- --- ---1")
nextcase2:
Case "K":
Selection.TypeText Email = ("4@m.org")
Selection.TypeText phone = ("8-- --- ---2")
nextcase3:
Case "E":
Selection.TypeText Email = ("5@m.org ")
Selection.TypeText phone = ("8-- --- ---3")
nextcase4:
Case "C":
Selection.TypeText Email = ("6@m.org")
Selection.TypeText phone = ("8-- --- ---4")
nextcase5:
Case "M":
Selection.TypeText Email = ("7@m.org")
Selection.TypeText phone = ("8-- --- ---5")
nextcase6:
Case "O":
Selection.TypeText Email = ("8@m.org")
Selection.TypeText phone = ("8-- --- ---6")
End Select
End Sub
I have given myself a crash course in vba programming by trying to make a word document with a drop down menu that has several different outputs
for example if you selected "N" in the drop down menu it would populate several different fields throughout the document
I have the drop down menu run the macro below on exit and at this point ive used the { email } field directly in the document and it states "Error bookmark not defined"
How do I output values from the macro into the word document?
thank you in advance for taking the time to point me in the right direction
code below:
Sub stest()
Dim servicearea As String
Dim Email As String
Dim phone As String
Email = "1@m.org"
phone = ("8-- --- ----")
Select Case servicearea
Case "N":
Selection.TypeText Email = ("2@m.org")
Selection.TypeText phone = ("8-- --- ----")
nextcase:
Case "S":
Selection.TypeText Email = ("3@m.org")
Selection.TypeText phone = ("8-- --- ---1")
nextcase2:
Case "K":
Selection.TypeText Email = ("4@m.org")
Selection.TypeText phone = ("8-- --- ---2")
nextcase3:
Case "E":
Selection.TypeText Email = ("5@m.org ")
Selection.TypeText phone = ("8-- --- ---3")
nextcase4:
Case "C":
Selection.TypeText Email = ("6@m.org")
Selection.TypeText phone = ("8-- --- ---4")
nextcase5:
Case "M":
Selection.TypeText Email = ("7@m.org")
Selection.TypeText phone = ("8-- --- ---5")
nextcase6:
Case "O":
Selection.TypeText Email = ("8@m.org")
Selection.TypeText phone = ("8-- --- ---6")
End Select
End Sub