通过VB5中的编码打开文件 [英] OPEN FILE THROUGH CODING IN VB5

查看:91
本文介绍了通过VB5中的编码打开文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 在VB5中选择列表框中的文件后,通过按钮打开文件时遇到问题。

弹出错误"对象必需"运行时错误424.

任何人都可以帮我搞清楚我犯错的地方。


实际编码为 



Private Sub CommandButton1_Click()

如果UserForm1.ListBox1.ListIndex< 0然后

MsgBox("SELECT A FILE .....")

否则

'做点什么..

Filename = UserForm1.ListBox1.List(UserForm1.ListBox1.ListIndex)

Filename =" c:\ Users \HP \DeskTop" &安培;文件名

Workbooks.Open(文件名)

结束如果

结束子



Private Sub UserForm_initialize()

Filename = Dir(" c:\ Users \HP \DeskTop"&" \ * .xlsx",vbNormal)

Do Len(文件名)> 0

UserForm1.ListBox1.AddItem文件名

Filename = Dir(" c:\ Users \HP \DeskTop")

循环

结束次级



问候



AM

解决方案

您好


我在通过命令按钮打开文件时遇到问题。


文件确实出现在列表框中但是在选择后点击按钮弹出一个错误说"需要对象"并且还"附带运行时错误424"


项目和表格以进行更正和指导。


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





欢呼


AM


 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

解决方案

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


这篇关于通过VB5中的编码打开文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆