weixin_44213624
2018-12-22 08:30VB6中APP.path的用法问题
APP.path在使用过程中,总不是很顺畅。经常报错,
如下代码,出现1004错误,无法打开对应的文件。
1、我确定文件位置和程序在一个文件下;
2、我过程检查插入print fullpath,所显示的地址是正确的;
3、我将显示的地址直接提换如下语句中的fullpath
Set xlBook = xlApp.Workbooks.Open("fullpath")
程序也能运行成功。
求大神指点一下迷津
Private Sub Command1_Click()
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
Dim fullpath As String
If Right(App.Path, 1) = "\" Then
fullpath = App.Path + "temp.xlsx"
Else
fullpath = App.Path + "\" + "temp.xlsx"
End If
Print fullpath
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("fullpath")
xlApp.Visible = True
Set xlsheet = xlBook.Sheets("sheet1")
Text1.Text = xlsheet.Range("A1").Value
xlBook.Close
xlApp.Quit
End Sub
- 点赞
- 回答
- 收藏
- 复制链接分享
1条回答
为你推荐
- VB6中APP.path的用法问题
- 小程序
- 开发语言
- 2个回答
- 同类型为什么要强制转换(自己强转成自己)/ASP.NET Web程序重复引用(引用来自同一文件)问题(已解决)?
- c#
- 3个回答