Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 17th, 2005, 08:49 AM
Authorized User
 
Join Date: Feb 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Checkbox on word document

hi,

When i set a checkbox on a document and i print the document the checkbox will be print also.
I don't want that.
How can i provide that it won't print with the document??

 
Old February 17th, 2005, 08:54 AM
Authorized User
 
Join Date: Oct 2004
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to shattered Send a message via Yahoo to shattered
Default

Right click on the object (in this case the checkbox) and select Format Control. Click on the properties tab and uncheck the Print Object check box

 
Old February 17th, 2005, 09:30 AM
Authorized User
 
Join Date: Feb 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes shattered you can do that in EXCEL, but not in word.

I know this is the form of excel vba but the form word vba does not excist as fare i have seen.


 
Old February 17th, 2005, 11:17 AM
Authorized User
 
Join Date: Jun 2003
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

To do this in Word VBA you'd need something like:

Code:
public Sub FilePrint()
  Dim wordShape As Word.inlineshape
  Dim foundControlShape As Boolean
  Dim printHiddenTextState As boolean

  For Each wordShape In ActiveDocument.InlineShapes
    with wordShape
      If .Type = wdInlineShapeOLEControlObject Then
        .Range.Font.Hidden = True
        foundControlShape = True
      End If
    end with
  Next

  printHiddenTextState = Application.Options.PrintHiddenText

  If foundControlShape Then
    Application.Options.PrintHiddenText = False
  End If

  Application.Dialogs(wdDialogFilePrint).Show

  If foundControlShape Then
    For Each wordShape in ActiveDocument.InlineShapes
      With wordShape
        If .Type = wdInlineShapeOLEControlObject Then
          .range.Font.hidden = false
        End If
      End With
    next
  End If

  application.Options.PrintHiddenText = printHiddenTextState
End Sub
Basically, you can loop through all OLE Control shapes in the document and set the hidden property of the font to True.

You may well need to beef up this code as it's only searching the body of the document for these control objects. Also, FilePrint only traps the Print option under the File menu (as well as Ctrl+P shortcut). To trap the print icon on the toolbar you'll need to declare a FilePrintDefault procedure, and do
 
Code:
ActiveDocument.PrintOut

rather than show the print dialog

good luck





Similar Threads
Thread Thread Starter Forum Replies Last Post
Export to word document lily611 General .NET 2 July 30th, 2013 04:44 AM
Word Document to PDF BSkelding ASP.NET 1.0 and 1.1 Professional 2 July 19th, 2013 04:53 AM
Protect a Word document zengfu Excel VBA 1 March 28th, 2005 11:00 AM
Protect a Word document zengfu Pro VB 6 0 March 28th, 2005 08:40 AM
ASP - Word Document mapaquin Classic ASP Professional 1 August 11th, 2003 06:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.