+ Reply to Thread
Results 1 to 6 of 6

Hiding Images via Macro

  1. #1
    Registered User
    Join Date
    11-17-2011
    Location
    australia
    MS-Off Ver
    2010
    Posts
    4

    Question Hiding Images via Macro

    Hi there, this is my first post here, just looking for some help with an assignment i've been given as my lecturer is useless.

    Sorry i meant to post this in Excel section.

    I have created a quiz with images that gives you point upon clicking the correct one, but the problem is you can click any image multiple times until you get the right one.

    I was looking for something that would work like this:

    Click Pic1 >
    Pic2, Pic3 and Pic4 all go invisible

    I know the macro command (.Visible = False) but im not sure how i would code this so it would work?

    Here's what my VB statement looks like at the moment

    Sub Picture6_Click()
    MsgBox "WRONG!", vbOKOnly, "Incorrect"
    Range("G73").Value = "0"
    End Sub
    _________________________________________________________
    Sub Picture7_Click()
    MsgBox "WRONG!", vbOKOnly, "Incorrect"
    Range("G73").Value = "0"


    End Sub
    _________________________________________________________
    Sub Picture8_Click()
    MsgBox "WRONG!", vbOKOnly, "Incorrect"
    Range("G73").Value = "0"


    End Sub
    _________________________________________________________
    Sub Picture9_Click()
    MsgBox "Correctamundo!", vbOKOnly, "Correct"
    Range("G73").Value = "2"


    End Sub
    And heres something i came up with (which encountered errors naturally).

    Sub Hide()
    If Picture6_Click = True Then
    Picture6.Visible = False
    ElseIf Picture7_Click() = True Then
    Picture7.Visible = False
    ElseIf Picture8_Click() = True Then
    Picture8.Visible = False
    Last edited by Sauc; 11-17-2011 at 04:16 AM.

  2. #2
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Hiding Images via Macro

    How about

    Picture6.Enabled = False

    Please Login or Register  to view this content.
    I think people forget the word "THANK YOU!!!!" Do you still know it???

    There is a little star ( ADD REPUTATION ) below those person who helped you. Click it to say your "PRIVATE APPRECIATION TO THEIR EFFORT ON THEIR CONTRIBUTIONS "

    Regards,
    Vladimir

  3. #3
    Registered User
    Join Date
    11-17-2011
    Location
    australia
    MS-Off Ver
    2010
    Posts
    4

    Re: Hiding Images via Macro

    I tried this but i get an error
    "Run-time error '424':
    object required.

    Thanks for the help.

    NOTE: Sorry i've realised now that this is in the wrong section, it was intended for Excel but i wasnt paying enough attention
    My apologies :p
    Last edited by Sauc; 11-17-2011 at 04:18 AM.

  4. #4
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Hiding Images via Macro

    Sorry didn't notice its a module

    try to move your codes to General
    then use
    private sub - end sub
    Please Login or Register  to view this content.

  5. #5
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Hiding Images via Macro

    Sampler to hide and unhide
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    11-17-2011
    Location
    australia
    MS-Off Ver
    2010
    Posts
    4

    Re: Hiding Images via Macro

    Quote Originally Posted by vlady View Post
    Sampler to hide and unhide
    Took this and modified slightly.

    Heres how it is
    Private Sub CommandButton1_Click()

    Image1.Visible = True
    Image2.Visible = True
    Image3.Visible = True
    Image4.Visible = True

    End Sub

    Private Sub Image1_Click()
    MsgBox "WRONG!!", vbOKOnly, "Incorrect"
    Range("G73").Value = "0"

    Image2.Visible = False
    Image3.Visible = False
    Image4.Visible = False
    So when i click one the rest go invisible. The Command Box is to reset it and is going to be locked.

    Thanks a lot vlady :D

+ 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