OzGrid

How to use a VBA Code for clipart

< Back to Search results

 Category: [Excel]  Demo Available 

How to use a VBA Code for clipart

 

Requirement:

 

The user would like to assign a macro to a Clipart image which,when clicked on will ask for a password and then take the user to another folder if the password is correct. (The folder is on a server if this makes any difference).

 

Solution:

 

Code:
Option Explicit
Private Declare Function SetCurrentDirectoryA Lib "Kernel32" _
        (ByVal sCurDir As String) As Long

Sub Picture1_Click()
Const sPwd As String = "Password"
Dim sInpPwd As String

sInpPwd = InputBox("Enter Password", "Password")
If sInpPwd = sPwd Then
    'specify Drive & Path to open
    bSetDir ("\\frodo\finance$\Finance Birmingham") 'or your path
    Application.GetOpenFilename
Else
    MsgBox "Incorrect Password"
End If

End Sub

Function bSetDir(anyDir As String) As Boolean
    If SetCurrentDirectoryA(anyDir) = 0 Then
        bSetDir = True
    End If
End Function

 

Obtained from the OzGrid Help Forum.

Solution provided by Will Riley.

 

See also: Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions and Index to new resources and reference sheets

 

See also:

 

How to use Excel VBA macro to convert multiple columns to multiple rows
How to create VBA to place current month and year in a cell
How to freeze panes using VBA
How to data trim and clean cell values with VBA code
How to use Excel VBA userform list box

 

Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions

 

 


Gallery



stars (0 Reviews)