• Preventing controls printing (Word97sr2 VBA)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Preventing controls printing (Word97sr2 VBA)

    Author
    Topic
    #360313

    This is probably a dumb question, but how can you prevent a button on a document from printing? I can find the property on Excel sheets but seem unable to set it in Word.

    Viewing 1 reply thread
    Author
    Replies
    • #542381

      Basically, you want users to be able to view a doc – but not print it?

      I had a similar question recently – also, they wanted to prevent copy/paste.

      I’m curious to hear the experts answer this.

    • #542383
      • #542563

        Thanks for the replies. I think i need to explain a bit more…
        I’m generating a multi-choice exam using an excel database of questions and responses. A VBA routine randomly selects a requested number of unique questions and scrambles the answers. A Word doc is used to hold the questions and answers, plus any graphic and the correct response. So the whole list of questions would be in the format:-

        Some question here?
        Response A goes here
        Response B goes here
        Response C goes here
        Response D goes here
        Correct reponse is: A – D

        The questions are formated as Heading 1style, the choices as Heading 2 style and the correct response para (which also holds any inline graphic) as Heading 3 style. Headings 1 and 2 are set up to outline number and Heading 3 has no number but does have a bottom border. The whole thing works very well, with all questions and responses automatically numbering and lettering plus any graphics below the last reponse being exactly the same width as the column. To toggle between hiding and showing the correct answers i placed a toggle button at the top of the first page to switch the font colour of the Heading 3 style between white and auto.

        I checked the FAQ and the text box technique is intresting (if a pain in the ass) but it assumes i want a button for printing. To get the sample code to work i would need to place a button on the document for printing. I even checked for event procedures like Before_print in excel, but no luck. All these things that are in one App but not another is enough to drive you nuts !!

        • #542569

          Okay, this really is cheating, but… how about putting a section break after the button and then only printing Section 2? I have a couple different automated Word solutions where the first section is data collection and plumbing, and Section 2 is the beautiful result.

          If that doesn’t work for you, how about hidden text? I am used to viewing hidden text, so it seems quite natural to me to use the hidden text attribute for that paragraph so it doesn’t print. However, I don’t know whether your users view hidden text. If not, they won’t see the button. This could be toggled in a Document_New or Document_Open macro, if you don’t mind messing with the user’s settings. (Storing the original value to restore on close is not a perfect solution because the user might work with other documents while your document is open…)

          All I can think of at the moment.

          • #542601

            I’ve decided to use a check box. It’s more discrete than some big grey toggle button and doesn’t require playing around with user settings (which can upset some!!) or putting buttons on the document to specifically hide controls during printing/print certain sections. I am assuming there is no equivalent to a print range in Excel, where once you name it you can leave it alone.
            Thanks for the input everyone,
            Ewan
            P.S. Could start a whole new thread on features in one office app that should be in the others!!

            • #544304

              Ewan,

              If you have the option to use Word 2000, you can take advantage of the application-level DocumentBeforePrint event (don’t think that existed in Word 97).

              Gary

    Viewing 1 reply thread
    Reply To: Preventing controls printing (Word97sr2 VBA)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: