View Single Post
 
Old 10-02-2015, 06:07 AM
kyeung kyeung is offline Windows 7 32bit Office 2007
Novice
 
Join Date: Oct 2015
Posts: 2
kyeung is on a distinguished road
Default ActiveX Textbox properties using VBA

Hi all,

So basically I have created a command button in the word document and I want it to create a new ActiveX Textboxes everytime I press it. I want it to preset to a certain Height and Width and with MultiLine and Vertical Scrollbar Enabled. Since I am not very familiar to VBA so I used the Record Macro option in the Developer tab. Here is the code:

************************************************** ***********
Sub ButtonForSoftwareOutputs()
'
' ButtonForSoftwareOutputs Macro
'
'
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.InlineShapes.AddOLEControl ClassType:="Forms.TextBox.1"
ActiveDocument.ViewPropertyBrowser
ActiveDocument.ViewPropertyBrowser
ActiveDocument.ViewPropertyBrowser
ActiveDocument.ViewPropertyBrowser
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.TypeParagraph
End Sub

************************************************** ***********

However, an error message pop up saying that "The ViewProperrtyBrowser method or property is not available because the current selection is an active control".

How should I write the code so that it can change the property of the ActiveX textbox? Thanks!
Reply With Quote