Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-04-2015, 04:51 PM
Eduardo Care Eduardo Care is offline Hide Macro Button when printing Windows 8 Hide Macro Button when printing Office 2010 64bit
Advanced Beginner
Hide Macro Button when printing
 
Join Date: Aug 2015
Location: Cali
Posts: 32
Eduardo Care is on a distinguished road
Default Hide Macro Button when printing

Hello people,



I attach a document where i have macro buttons that show and hide text on a protected document, so the user can chose have them or not, but i would like to hide those buttons too when i printing the document.

Do you people know what i can do for this?

Any idea/tutorial/link to possible solution its welcome.

Thanks in Advance.
Attached Files
File Type: docx Example.docx (14.1 KB, 18 views)
Reply With Quote
  #2  
Old 11-04-2015, 05:30 PM
Eduardo Care Eduardo Care is offline Hide Macro Button when printing Windows 8 Hide Macro Button when printing Office 2010 64bit
Advanced Beginner
Hide Macro Button when printing
 
Join Date: Aug 2015
Location: Cali
Posts: 32
Eduardo Care is on a distinguished road
Default

UPDATE:

I add the following Code

Code:
Sub FilePrint()
    With ActiveDocument

        .Bookmarks("ShowHide1").Range.Font.Hidden = True
        .Bookmarks("ShowHide2").Range.Font.Hidden = True
        Application.ScreenRefresh
        With Dialogs(wdDialogFilePrint)
            .Show
        End With
        .Bookmarks("ShowHide1").Range.Font.Hidden = False
        .Bookmarks("ShowHide2").Range.Font.Hidden = False

    End With
End Sub
But only works if the document its not protected, i don't know if i could work on this or look for another alternative.
Reply With Quote
  #3  
Old 11-04-2015, 08:01 PM
macropod's Avatar
macropod macropod is online now Hide Macro Button when printing Windows 7 64bit Hide Macro Button when printing Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You could instead apply a unique Style to each of the ranges whose visibility you want to toggle, then simply change the Style's font visibility attribute. For example:
Code:
Sub FilePrint()
With ActiveDocument
  .Styles("Instructions").Font.Hidden = True
  Application.ScreenRefresh
  Dialogs(wdDialogFilePrint).Show
 .Styles("Instructions").Font.Hidden = False
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #4  
Old 11-05-2015, 05:55 PM
Eduardo Care Eduardo Care is offline Hide Macro Button when printing Windows 8 Hide Macro Button when printing Office 2010 64bit
Advanced Beginner
Hide Macro Button when printing
 
Join Date: Aug 2015
Location: Cali
Posts: 32
Eduardo Care is on a distinguished road
Default

That works perfect, but still only works when the document isnt protected, when i print to run the macro while the document have protection from editing i get the msg:

"This method or property is not available because the document is locked for editing"

Any idea to solve this or perhaps im not using the code properly?
Reply With Quote
  #5  
Old 11-05-2015, 06:11 PM
macropod's Avatar
macropod macropod is online now Hide Macro Button when printing Windows 7 64bit Hide Macro Button when printing Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Well, there are field coding solutions (i.e. no macros required) that should work regardless of document protection. To provide instructions that disappear
• permanently once the document is printed, you could use a field coded as:
{IF{PRINTDATE \@ yyyy}= 0 "Instructions"}
• temporarily when the document is printed, you could use a field coded as:
{IF{PRINTDATE \@ yyyyMMddHHmm}= {DATE \@ yyyyMMddHHmm} "" "Instructions"}
With this second approach, the instructions can be made to re-appear via anything that causes the fields to update (e.g. a print preview or tabbing out of a formfield that has the 'calculate on exit' property set) but you may have to wait for up to a minute after printing to do that.

The alternative is to code the macro to temporarily switch off protection while updating the Style/formatting.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 11-05-2015, 06:53 PM
Eduardo Care Eduardo Care is offline Hide Macro Button when printing Windows 8 Hide Macro Button when printing Office 2010 64bit
Advanced Beginner
Hide Macro Button when printing
 
Join Date: Aug 2015
Location: Cali
Posts: 32
Eduardo Care is on a distinguished road
Default

Thanks alot Paul, i will try both of the solutions.
Reply With Quote
  #7  
Old 11-09-2015, 04:19 PM
Eduardo Care Eduardo Care is offline Hide Macro Button when printing Windows 8 Hide Macro Button when printing Office 2010 64bit
Advanced Beginner
Hide Macro Button when printing
 
Join Date: Aug 2015
Location: Cali
Posts: 32
Eduardo Care is on a distinguished road
Default

Hi Paul i end up using the second alternative you suggest me, for anyone interested ill leave the code:

Code:
Sub FilePrint()
    With Application.ActiveDocument
        If .ProtectionType <> wdNoProtection Then _
        .Unprotect Password:="Password"
        With ActiveDocument
            .Styles("TEST1").Font.Hidden = True
            Application.ScreenRefresh
            Dialogs(wdDialogFilePrint).Show
            .Styles("TEST1").Font.Hidden = False
         .Protect wdAllowOnlyReading, True, "Password"
        End With
    End With
End Sub
Its just a macro that unprotect the document, next i use macro Paul told me to use to hide the text, and finally reprotect the document.

This macro can hide any kind of text you might need, not only macro buttons so i hope someone else find i usefull, all you need to do its change the style of the text you want to hide, in my case i create a new one that i call "TEST1" but you can name it as you wish.


Thanks alot Paul, you saved me.

Last edited by Eduardo Care; 11-09-2015 at 06:48 PM.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide Macro Button when printing Want to show/hide mutiple grouped coloumns in Excel sheet with a button abutahir Excel 4 11-03-2015 01:07 PM
How to hide the Audio Icon while PRINTING chrismhart PowerPoint 1 10-30-2014 03:33 PM
Hide Macro Button when printing Hide Checkbox When Printing vinceplunkett Word 1 12-03-2013 01:53 AM
Hide Macro Button when printing Assign macro but hide the button/field trlear Word VBA 5 02-23-2012 04:35 PM
Hide Macro Button when printing Button in hidden section won't hide Joe Patrick Word 6 06-07-2011 09:31 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:31 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft