简体   繁体   English

如何使用VBA通过Internet Explorer从共享点打开Excel文档

[英]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.

相关问题 使用Excel VBA从Internet Explorer提取数据集-如何与弹出的保存/打开/保存进行交互 - Using Excel VBA to pull datasets from internet explorer - how to interact with save/open/save as pop up 在没有Internet Explorer的情况下通过Web通过VBA(Excel)打开图片 - Open picture via VBA ( Excel) from web without Internet Explorer 如何在Excel VBA Internet Explorer中使用通配符 - How to use wildcard in excel vba internet explorer SendKeys从Internet Explorer打开Excel文件 - SendKeys to open Excel file from Internet Explorer 通过直接程序路径在Excel VBA中打开Internet Explorer - Open Internet Explorer In Excel VBA through direct program path 当使用VBA直接从Internet Explorer打开CSV文件时,我无法与该文件进行交互。 - When using VBA to open a CSV file directly from internet explorer, I cant then Interact with the file. 使用excel vba标记Internet Explorer中的所有复选框 - mark all check boxes in internet explorer using excel vba 使用Excel VBA在Internet Explorer文本框中输入一个值 - Using Excel VBA to input a value into Internet Explorer textbox ADVISE:从Excel VBA访问Internet Explorer中的PHP对象 - ADVISE: Accessing PHP Objects in Internet Explorer from Excel VBA VBA:从现有的打开的Internet Explorer选项卡中复制数据/文本 - VBA: Copy data/text from an existing open Internet Explorer tab
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM