[英]Error in addressing an open Excel file, using VBA in PowerPoint
I am trying to have a vba macro in PowerPoint to open and retrieve information from an Excel file. 我试图在PowerPoint中使用vba宏来打开和检索Excel文件中的信息。 The Excel file is saved in a SharedPoint and I am able to open it.
Excel文件保存在SharedPoint中,我可以打开它。 However, when I want to refer to the Workbook as to retrieve information from it's cells, it gives me the following error:
Automation error invalid syntax -2147221020 (800401e4)
但是,当我想参考工作簿以从其单元中检索信息时,它给了我以下错误:
Automation error invalid syntax -2147221020 (800401e4)
Here is the code I have so far: 这是我到目前为止的代码:
Sub test()
Dim wb As Excel.Workbook
Dim ws As Excel.Worksheet
Application.DisplayAlerts = False
'open excel from sharedpoint
ActivePresentation.FollowHyperlink _
Address:="http://teams.blabla.com/Shared%20Documents/Overview_NPD_Projects.xlsm", _
NewWindow:=True, AddHistory:=True
Set wb = GetObject("http://teams.blabla.com/Shared Documents/Overview_NPD_Projects.xlsm")
' this does not work even when I change it to "Shared%20Documents"
Set ws = wb.Worksheets("Project List")
auxvariable = ws.Range("B2").Value
End Sub
The funny thing is that it works if I try to save the excel file manually to my desktop before running the macro and change the the path to: 有趣的是,如果我在运行宏并将路径更改为之前尝试将excel文件手动保存到桌面上,它将起作用。
Set wb = GetObject("C:\Users\Filipe.freitas\Desktop\Overview_NPD_Projects.xlsm")
I would save the file to the desktop and use the correct path, but I would need to refer to the excel file before doing it. 我会将文件保存到桌面并使用正确的路径,但是在执行此操作之前,我需要先参考excel文件。 Any help would be greatly appreciated!
任何帮助将不胜感激!
Have you tried http://www.cpearson.com/Excel/DownloadFile.aspx and then 您是否尝试过http://www.cpearson.com/Excel/DownloadFile.aspx ,然后
Dim xlapp as object
xlapp = createobject("Excel.Application")
set wb = xlapp.workbooks.open("thefilenamewhereyousavethedownload")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.