Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a Word Document using VBA

Status
Not open for further replies.

one234

IS-IT--Management
Mar 8, 2003
728
GB
Hello All,

I want to make a word document using VBA.

I have created a new document and placed a Command Button on it. If the user clicks on the button an user forms opens and shows the available option that can be added in the document.

The User form was no problem, I can also filter the selected options, but currently I'm having problems with hiding the initial button.

I have tried the following code:
Code:
    If ActiveDocument.Shapes("CommandButton2").Visible = True Then
        ActiveDocument.Shapes("CommandButton2").Visible = False
    End If

I checked it using:
Code:
    MsgBox ActiveDocument.Shapes.Count
    MsgBox ThisDocument.Shapes.Count

But both counts returned 0...

If I use this code in Excel it works fine...

I also do not know how to add text to the document using VBA, can somebody tell me that as well??

Thx.

Marc D.


No trees were killed in the sending of this message. However a large number of electrons were terribly inconvenienced.
 
Hi,
Control objects all have similar properties and many have different properties. In Word, the CommandButton does not have a Visible property. Just take a look at the properties window to see the available properties.

As far as adding text to a document, try recording adding text. Then modify that code to suit your needs.

Skip,
Skip@TheOfficeExperts.com
 
Thx for the information...

But how do I remove/hide the button then???

No trees were killed in the sending of this message. However a large number of electrons were terribly inconvenienced.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top