If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
mail merge file button
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").CodeMod ule.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. |
Thread Tools | |
Display Modes | |
|
|