Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Run time error '424'

Posted on 2009-04-02
6
415 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 143

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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

856 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