Solved

Run time error '424'

Posted on 2009-04-02
6
412 Views
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, _

         Title:=Title)

 

'   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

0
Comment
Question by:TITO2009
  • 4
6 Comments
 
LVL 142

Accepted Solution

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

Author Comment

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

Expert Comment

by:Rory Archibald
ID: 24047862
And none of your file types are image files anyway! :)
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

Author Comment

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

Author Comment

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

Author Comment

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

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Troubleshooting a Worksheet Graphic 8 25
ADD New Entries 7 15
Why doesn't duplicate values work on this spreadsheet? 6 31
Auto Adjust Percent rate 5 26
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

914 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now