[英]How to Open an Excel Document from Share Point by Internet Explorer using VBA
Am new to VBA & trying to learn as I go. VBA的新手,我想边学习边学习。 Am currently stuck with an Issue here which I need some help. 目前在这里遇到问题,我需要一些帮助。
Am trying to open an Excel workbook( Test.xlsx
) from the share point using Internet Explorer. 我正在尝试使用Internet Explorer从共享点打开Excel工作簿( Test.xlsx
)。 Once the File is opened, I would like to close IE. 打开文件后,我想关闭IE。 Then copy few Sheets from the Workbook, copy/Move it to a new Workbook & close the original Workbook. 然后从工作簿中复制几张图纸,将其复制/移动到新工作簿并关闭原始工作簿。 I searched a lot in Google & came with below codes which works OK if I run it separately, but If I combine with my original program (which I manged to generate by recording Macros) it gives an Error message 'Run-time error'9': Subscript out of range'which when I debug will highlight my Error Handler Code (Workbooks("Test.xlsx").Close SaveChanges:=False)
. 我在Google中进行了大量搜索,并提供了以下代码,如果我分别运行它,则可以正常运行,但是如果我与原始程序结合使用(我通过记录宏来生成该程序),则会显示错误消息“运行时错误” 9 ':下标超出范围',当我调试时将突出显示我的错误处理程序代码(Workbooks("Test.xlsx").Close SaveChanges:=False)
。
I really cant understand the mistake here. 我真的不明白这里的错误。 Can someone please help me with the correct codes here. 有人可以在这里提供正确的代码帮助我。
Basically my requirement is to open an Excel Workbook from Share point( "URL/TEST.xlsx"
) using Internet Explorer(in a new window),close IE window & then to copy/move few sheets from the original Workbook(Test.xlsx) to new Workbook, close the original workbook(Test.xlsx) & make amendments in the new workbook(Book##). 基本上,我的要求是使用Internet Explorer(在新窗口中)从共享点( "URL/TEST.xlsx"
)打开Excel工作簿,关闭IE窗口,然后从原始工作簿中复制/移动几张纸(Test.xlsx) )到新工作簿,请关闭原始工作簿(Test.xlsx)并在新工作簿(Book ##)中进行修改。
Can someone please help me with the codes here. 有人可以帮我这里的代码。
Below are the codes I managed to get from Google/Internet. 以下是我设法从Google / Internet获得的代码。
Sub OpenIE()
Dim objIE As Object
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate "URL/TEST.xlsx"
objIE.Visible = True**
On Error GoTo My_Error_Handler
Windows("Test.xlsx").Visible = True
On Error GoTo My_Error_Handler
Sheets(Array("Stats", "Mtx")).Select
Sheets("Mtx").Activate
Sheets(Array("Stats", "Mtx")).Copy
Sheets("Mtx").Select
'
'
'
'
' so on
'
'
My_Error_Handler:
Workbooks("Test.xlsx").Close SaveChanges:=False
ActiveWorkbook.Close SaveChanges:=False
MsgBox "Error: (" & Err.Number & ") " & Err.Description, vbCritical
End Sub
Thanks 谢谢
Sub SP()
Application.Workbooks.Open "http://123/Testing/Test.xlsx"
End Sub
Or if you want to automatically check it out too 或者,如果您也想自动签出
Sub SP()
fil = "http://123/Testing/Test.xlsx"
If Application.Workbooks.CanCheckOut(fil) Then
Application.Workbooks.CheckOut fil
Set wb = Application.Workbooks.Open(fil)
End If
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.