+ Reply to Thread
Results 1 to 11 of 11

Macro to Disable Hyperlink when file is ReadOnly

  1. #1
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    991

    Macro to Disable Hyperlink when file is ReadOnly

    Hello All,

    I have a sheet that has six images and each has a Hyperlink assigned to each.

    The Need:

    When the User does not enter the correct Password to access the sheet, functionality of the sheet is turned ReadOnly.

    That being said, the Hyperlink assigned to each Image still functions and the user can access material that is only for those who have entered the correct password.

    Needing to discuss what may be put into the worksheet that if the User status is set to ReadOnly the Hyperlinks become inactive!

    Any thoughts??

    Best Regards,

    John

  2. #2
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Macro to Disable Hyperlink when file is ReadOnly

    One way would be to hide all but the "Safe" sheets at workbook close. On open, If ThisWorkbook.ReadOnly Then, show just sheets that you want. Else, show all or Write status sheets.

  3. #3
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    991

    Re: Macro to Disable Hyperlink when file is ReadOnly

    Hi Kenneth,

    Thanks for you input - I really appreciate that!

    My apologies - I should have explained in more detail... The User that has ReadOnly access are able to read the data that is on the sheet... Hiding that data would defeat the purpose of them being able to read the information.. I discovered that when the User has ReadOnly access they cannot interact with some portions of the file but they were able to select the image and launch a Publisher file which is intended only for those with complete access

    Regards,

    John
    Last edited by JJFletcher; 09-24-2017 at 08:45 PM. Reason: grammer

  4. #4
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Macro to Disable Hyperlink when file is ReadOnly

    Right, duplicate the sheet and remove the hyperlink for the readonly version. e.g.
    Please Login or Register  to view this content.
    [/CODE
    Of course any such file can be hacked. Be sure to protect the vbaproject as well. Mainly, this just provides a modicum of protection.

  5. #5
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    991

    Re: Macro to Disable Hyperlink when file is ReadOnly

    Thanks Kenneth,

    I'll make a version of that and see how it functions

    Regards

    John

  6. #6
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    991

    Re: Macro to Disable Hyperlink when file is ReadOnly

    It's been suggested I do the following... what would that look like in code?

    Set a public variable when checking the password that exits the Click-event of the image when in readonly –mode.

    Regards,

    John

  7. #7
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,358

    Re: Macro to Disable Hyperlink when file is ReadOnly

    Put this in ThisWorkbook.

    Please Login or Register  to view this content.
    and this in a Standard module.

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  8. #8
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    991

    Re: Macro to Disable Hyperlink when file is ReadOnly

    Hi backerman2,

    I tried the code suggested and it did not stop the hyperlink... when in ReadOnly status - could still select the hyperlink

    Kenneth,

    I have not created your suggestion yet - will get to it though!

    Regards,

    John

  9. #9
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,358

    Re: Macro to Disable Hyperlink when file is ReadOnly

    I'm assuming the images are in ActiveX ImageObjects and the hyperlinks are activated by using the Click-event of the object and the FollowHyperlink-method ?

  10. #10
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    991

    Re: Macro to Disable Hyperlink when file is ReadOnly

    Hi backerman2

    Thanks for your reply...

    there are three images in one... dark image, light image these are active X... There is a square shape added between the two Active X Images - and that shape has the hyperlink attached using the insert link process and entering the Publisher file

    Regards,

    John

  11. #11
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,358

    Re: Macro to Disable Hyperlink when file is ReadOnly

    Instead of assigning a hyperlink, assign each shape to 1 general peace of code with a Select Case. Depending on which Shape is calling the code assign the correct path to the Publisher-file to a variable and use that variable in the FollowHyperlink-method. Doing it like this you could set the public variable on opening the workbook and checking the password. Then checking the state of the public variable on top of the general code should give you the possibility to exit or push forward with the code.
    Something like.

    In this workbook.
    Please Login or Register  to view this content.
    In a standard module.
    Please Login or Register  to view this content.
    Now assign to each shape the code Open_PubFile instead of the hyperlink and make sure the ShapeNames are correct.
    Last edited by bakerman2; 09-26-2017 at 12:44 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Wait on File.readonly
    By evertjvr in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-17-2015, 04:32 AM
  2. [SOLVED] readonly file
    By cadone in forum Excel General
    Replies: 7
    Last Post: 12-19-2014, 06:46 PM
  3. [SOLVED] Open workbook if not readonly. If readonly try again.
    By Metrazal in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-29-2014, 02:45 PM
  4. VBA Make Closed File ReadOnly (FSO)
    By KRAND in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-28-2011, 08:57 AM
  5. Changing file from readonly
    By Niall in forum Excel General
    Replies: 2
    Last Post: 07-27-2006, 12:05 PM
  6. [SOLVED] How do I use VC++6.0 to protect a excel file to readonly
    By gowinder in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-21-2005, 10:05 PM
  7. How do I use VC++6.0 to protect a excel file to readonly
    By gowinder in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-21-2005, 10:05 PM

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