Hello,
I want to add a command button to a mail merge. The code I am using to generate the button is Sub Test() 'Add a command button to a new document Dim doc As Word.Document Dim shp As Word.InlineShape Set doc = Documents.Add Set shp = doc.Content.InlineShapes.AddOLEControl(ClassType:="Forms.CommandButton.1") shp.OLEFormat.Object.Caption = "Click Here" 'Add a procedure for the click event of the inlineshape '**Note: The click event resides in the This Document module Dim sCode As String sCode = "Private Sub " & shp.OLEFormat.Object.Name & "_Click()" & vbCrLf & _ " MsgBox ""You Clicked the CommandButton""" & vbCrLf & _ "End Sub" doc.VBProject.VBComponents("ThisDocument").CodeModule.AddFromString sCode End Sub
This code creates a button in the document that when clicked displays the "You clicked the CommandButton". Instead of this message I would like it to goto a specified location. Any ideas on how to do this would be appreciated. Thanks.
|
|