View Single Post
  #1   Report Post  
rutica rutica is offline
Junior Member
 
Posts: 14
Default make buttons invisible

I have a Microsoft Word 2003 document that has mail merge fields with Excel as its data source.

I created a few command buttons on my main form. One button allows the user to select the data source, one allows the user to select recipients and the third Merges the data and creates a new document.

I would like those command buttons to *not* appear on the newly created documents.

Here is my code for the button that creates the new document:

Private Sub cmdMergeDocument_Click()
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True

Me.cmdSelectDataSource.Visible = False 'this doesn't work!
Me.cmdMergeDocument.Visible = False 'this doesn't work!
Me.cmdSelectRecipients.Visible = False 'this doesn't work!

With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With

'now show the buttons again on the main form
Me.cmdSelectDataSource.Visible = True 'this doesn't work!
Me.cmdMergeDocument.Visible = True 'this doesn't work!
Me.cmdSelectRecipients.Visible = True 'this doesn't work!
End Sub

I get 'Object doesn't support this property or method'.

I am able to do: cmdSelectDataSource.Enabled = False, but it's not what I need. I need the buttons invisible, not disabled.

Help!
Thanks,