Word make table of contents clickable

broken image

Once the macro 'Test' finishes running, you will see a new CommandButton control on a new document.

broken image

' MsgBox ''You Clicked the CommandButton''' & vbCrLf & _ĭoc.VBProject.VBComponents('ThisDocument').CodeModule.AddFromString sCode SCode = 'Private Sub ' & & '_Click()' & vbCrLf & _ '**Note: The click event resides in the This Document module 'Add a procedure for the click event of the inlineshape

broken image

Set shp = (ClassType:='Forms.CommandButton.1') Insert a new module, and then add the following code example. Select the reference for Microsoft Visual Basic for Applications Extensibility. Press Alt+F11 to go to the Visual Basic Editor.

broken image

The ability to manipulate the Visual Basic Project of a Microsoft Office document at run-time requires a reference to the Microsoft Visual Basic for Applications Extensibility library.

broken image