Problem with command button

J

juan

Hi,
I have a protected document and a command button in it to call a userform to
input some values in a table, it works fine but when I try to print the doc,
the comman button is printed out too. Is there any way to tell word not to
print the command button?

Thanks
Juan Uribe
 
G

Greg Maxey

The only way I know to do that is to intercept the various Print commands
and run code something like this:

Public Sub FilePrint()
' intercepts File > Print (Ctrl+P)
HideResetCommand
Dialogs(wdDialogFilePrint).Show
ShowResetCommand
End Sub
Public Sub FilePrintDefault()
' intercepts Print button
HideResetCommand
ActiveDocument.PrintOut Background:=True
ShowResetCommand
End Sub
Public Sub FilePrintPreview()
HideResetCommand
ActiveDocument.PrintPreview
End Sub
Public Sub ClosePreview()
ActiveDocument.ClosePrintPreview
ShowResetCommand
End Sub
Sub HideResetCommand()
Dim oCtr
Set oCtr = ActiveDocument.Shapes(1)
oCtr.OLEFormat.Object.Caption = ""
oCtr.Width = 0
oCtr.Height = 0
End Sub
Sub ShowResetCommand()
Dim oCtr
Set oCtr = ActiveDocument.Shapes(1)
oCtr.OLEFormat.Object.Caption = "Reset Form"
oCtr.LockAspectRatio = msoFalse
oCtr.Height = 24
oCtr.Width = 72
End Sub

If you have other controls or shapes in your document then you will need to
revise the code above so that it works on the control of interest.
 
J

juan

thanks Greg...
or how to create a new menu item in "Insert" to call the userform....
the code in the command button is this
Private Sub CommandButton1_Click()
PideDatos.Show
End Sub

....and this way I will delete the command button
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top