我正在尝试创建一个visio图表,单击一个按钮,它会搜索并优先处理" location"一旦它在excel文件中找到该位置,它就会复制一个URL并继续使用默认浏览器打开该URL。我一直得到运行时错误438:对象不支持此属性或方法。有什么想法吗?
Option Compare Text
Private Sub Mail_Room_Click()
Dim XLApp As Excel.Application
Dim XLWB As Excel.Workbook
Set XLApp = New Excel.Application
Set XLWB = XLApp.Workbook.Open("C:\printers\schprint.xlsx")
Set XLWsht = XLWB.Sheets(1)
Dim URL As String
Dim Location As String
Location = "Mail Room"
URL = ""
For Each i In XLWsht.Range("D2:D11")
If StrComp(i.Cells.Value, Location) = 0 Then
URL = i.Cells.Offset(7, 0).Value
Exit For
End If
Next i
CreateObject("WScript.Shell").Run (URL)
End Sub
答案 0 :(得分:0)
我认为你只是因为' s'在XLApp.WorkbookS.Open中(" C:\ printers \ schprint.xlsx") 这应该可以解决问题。