Run time error '424'

Posted on 2009-04-02
Medium Priority
Last Modified: 2012-05-06
I am getting run time error after trying to paste picture on commandbutton surface

Private Sub CommandButton1_Click()
MsgBox "You selected " & GetImportFileName
CommandButton1.Picture = GetImportFileName    '<--RUN TIME ERROR '424' 
End Sub
Function GetImportFileName() As Variant
    Dim Filt As String
    Dim FilterIndex As Integer
    Dim FileName As Variant
    Dim Title As String
'   Set up list of file filters
    Filt = "Text Files (*.txt),*.txt," & _
           "Lotus Files (*.prn),*.prn," & _
           "Comma Separated Files (*.csv),*.csv," & _
           "ASCII Files (*.asc),*.asc," & _
           "All Files (*.*),*.*"
'   Display *.* by default
    FilterIndex = 5
'   Set the dialog box caption
    Title = "Select a File to Import"
'   Get the file name
    FileName = Application.GetOpenFilename _
        (FileFilter:=Filt, _
         FilterIndex:=FilterIndex, _
'   Exit if dialog box canceled
    If FileName = False Then
        MsgBox "No file was selected."
        Exit Function
    End If
'   Display full path and name of the file
    GetImportFileName = FileName
End Function

Open in new window

Question by:Rama Tito
  • 4
LVL 143

Accepted Solution

Guy Hengel [angelIII / a3] earned 1500 total points
ID: 24047276
CommandButton1.Picture  does not accept a string with the filename, but needs to get assigned the picture object.

Author Comment

by:Rama Tito
ID: 24047840
Hi, May i know how to assign picture object. Thanks
LVL 85

Expert Comment

by:Rory Archibald
ID: 24047862
And none of your file types are image files anyway! :)
Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.


Author Comment

by:Rama Tito
ID: 24056178
I am sorry,  could get the meaning. How to do that.

Author Comment

by:Rama Tito
ID: 24056189
My objective is by click command button, I must able to select picture on paste on button surface.

Author Comment

by:Rama Tito
ID: 24056304
Thank you, i did manage to over come the problem. Cheers

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
Manually copying shapes and their assigned macros one by one to a new location can be tedious, but if you use the Excel utility workbook attached to this article, the process will be much quicker and easier.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

600 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question