none
OPEN FILE THROUGH CODING IN VB5 RRS feed

  • Question

  •  am facing problem in opening the file through button after selecting a file in listbox in VB5.
    An error pop up " Object Required" Run time error 424.
    Can anyone help me in figuring out where I am making mistake.

    Actual coding is as 

    Private Sub CommandButton1_Click()
    If UserForm1.ListBox1.ListIndex < 0 Then
    MsgBox ("SELECT A FILE .....")
    Else
    'do something..
    Filename = UserForm1.ListBox1.List(UserForm1.ListBox1.ListIndex)
    Filename = "c:\Users\HP\DeskTop" & Filename
    Workbooks.Open (Filename)
    End If
    End Sub

    Private Sub UserForm_initialize()
    Filename = Dir("c:\Users\HP\DeskTop" & "\*.xlsx", vbNormal)
    Do While Len(Filename) > 0
    UserForm1.ListBox1.AddItem Filename
    Filename = Dir("c:\Users\HP\DeskTop")
    Loop
    End Sub


    Regards

    AM

    Wednesday, September 13, 2017 6:00 AM

All replies

  • Hi

    I am gacing a problem in file opening through command button.

    Files do appear in list box but after selecting and clicking button an error pop up says"object required" and also " Runtime error 424"

    project and form is attached for correction and guidance.

    https://1drv.ms/f/s!ApB75VvFFQtogS9TnX0apY5wHADQ


    cheers

    AM

    Tuesday, September 12, 2017 5:50 PM
  • Yea this we get when Moderators don't move this kind of questions to Off Topic, search engines start pointing to this forum. 

    However, VB5 is not a supported program language, the runtime is not running anymore on the newer Microsoft OS systems. 


    Success
    Cor

    Tuesday, September 12, 2017 6:47 PM
  • VB5 quiestons are not done in this forum.

    (As earlier told to you)

    They are of topic


    Success
    Cor

    Wednesday, September 13, 2017 6:08 AM
  • Hello,

    VB 5 is no longer supported by Microsoft.

    I'd suggest upgrading to the free Visual Studio Community Edition or to a paid Visual Studio version.

    If you really want to use VB 5, which has been out of support since June 2003, I'd suggest using your favorite search engine to find a third party support forum.

    Karl


    Wednesday, September 13, 2017 3:03 PM
    Moderator