Solved

Run time error '424'

Posted on 2009-04-02
6
413 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

813 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