+ Reply to Thread
Results 1 to 11 of 11

Hide picture by default, display if macros enabled

  1. #1
    Registered User
    Join Date
    04-07-2008
    Posts
    4

    Hide picture by default, display if macros enabled

    Hi all,

    Basically, I want cell A1 to display the message "Macros must be enabled for this document to display properly", then have that text replaced with a picture (jpeg logo) if macros are enabled. I know I need to put the code in the Workbook_Open sub, but I keep getting the "error 1004, cannot modify visible property of picture object" when I try to tinker with "visible = true".

    *EDIT* - The picture must be embedded in the spreadsheet somehow, and hidden from view when macros are disabled. (Having the picture crammed into a single cell at IV65536 is fine.)

    Thoughts?

    Thanks!

    -PhearoX
    Last edited by PhearoX; 04-07-2008 at 02:19 PM.

  2. #2
    Registered User
    Join Date
    02-28-2008
    Posts
    36
    Sorry I cant help you out on this one, but it sounds like a great feature. I have a workbook that is used by several users, not all of them are familar with excel. I would like to see the code that you are using so far and adapt it so if macros are disabled a massage would show on the front page telling them step by step instructions on how to enable macros. Then after the macros are enabled so the workbook would perform properly this message would be hidden.
    Thanks for the idea

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    is this what you mean?
    Attached Files Attached Files
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Forum Contributor
    Join Date
    03-24-2005
    Location
    Wisconsin
    MS-Off Ver
    2007
    Posts
    378

    The same thing will work for pictures, just...

    Quote Originally Posted by royUK
    is this what you mean?
    The same code works for pictures, inserted in the sheet. When you click on the picture you should see then name Excel gives, in the name box to the left of the formula bar. Just substitute that name for the text box you want visible if macros have been enabled.

    You can also hide you primary sheet on closing via VBA, and unhide and activate in with the opening VBA.
    Thanks!
    Dennis

    I am using Windows 7 and Office 2007, all of my posts are based on this.

  5. #5
    Registered User
    Join Date
    04-07-2008
    Posts
    4
    Thanks for the advice, but I can't seem to get it to work... That excel sheet does exactly what I need, but I can't get it adapted for whatever reason.

    Here's my code:

    Please Login or Register  to view this content.
    Both Cell "A1" and the picture "Picture 1" are always visible, whether or not macros are enabled. I tried many different ways around this code, used Range instead of Cells, used ActiveSheet instead of Sheet1, tried specifying Picture(1) and Picture("Picture 1"), none of which work.

    Any other thoughts?

    Thanks!

  6. #6
    Registered User
    Join Date
    04-07-2008
    Posts
    4
    This is very strange... Even the code below doesn't do anything...

    Please Login or Register  to view this content.
    Am I missing something here?

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Please Login or Register  to view this content.
    This code works fine

    Please Login or Register  to view this content.
    Are you putting the code in the correct modules?

  8. #8
    Registered User
    Join Date
    04-07-2008
    Posts
    4
    Hah! Sure enough, I was putting the code in Sheet1 instead of ThisWorkbook.

    Thanks again for the help!

  9. #9
    Registered User
    Join Date
    02-28-2008
    Posts
    36
    Is there anyway to get this to come up in a message box instead of a range?

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    03-13-2008
    Posts
    52
    Please Login or Register  to view this content.
    Hope that helps - not too sure it will but you asked for MsgBox's!

    ~Liam

  11. #11
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    If macros aren't enabled then the message box will not display on opening, therefore the user may not be aware of the need to enable macros. That's why this type of code requires a visual message - a sheet or image, to make the user aware that macros need enabling.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1