Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2007

Tip: Looking for answers? Try searching our database.

Problem with command button

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
juan - 27 Sep 2007 21:59 GMT
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
Greg Maxey - 27 Sep 2007 22:21 GMT
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.

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> Hi,
> I have a protected document and a command button in it to call a
[quoted text clipped - 4 lines]
> Thanks
> Juan Uribe
juan - 27 Sep 2007 22:42 GMT
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

> The only way I know to do that is to intercept the various Print commands
> and run code something like this:
[quoted text clipped - 46 lines]
> > Thanks
> > Juan Uribe
Greg Maxey - 27 Sep 2007 22:53 GMT
Juan,

Just add you current UserForm calling macro to the a toolbar or menu.  See:

http://word.mvps.org/FAQs/Customization/AsgnCmdOrMacroToToolbar.htm

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> thanks Greg...
> or how to create a new menu item in "Insert" to call the userform....
[quoted text clipped - 62 lines]
>>> Thanks
>>> Juan Uribe
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.