How to Open an Excel Document from Share Point by Internet Explorer using VBA

deepak004

New Member
Joined
Jan 20, 2015
Messages
2
Am new to VBA & trying to learn as I go. Am currently stuck with an Issue here which I need some help.

Am trying to open an Excel workbook(<code style="margin: 0px; padding: 1px 5px; border: 0px; font-size: 13px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; white-space: pre-wrap; background-color: rgb(238, 238, 238);">Test.xlsx</code>) from the share point using Internet Explorer. Once the File is opened, I would like to close 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 <code style="margin: 0px; padding: 1px 5px; border: 0px; font-size: 13px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; white-space: pre-wrap; background-color: rgb(238, 238, 238);">(Workbooks("Test.xlsx").Close SaveChanges:=False)</code>.

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(<code style="margin: 0px; padding: 1px 5px; border: 0px; font-size: 13px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; white-space: pre-wrap; background-color: rgb(238, 238, 238);">"URL/TEST.xlsx"</code>) 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##).

Can someone please help me with the codes here.

Below are the codes I managed to get from Google/Internet.


<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; white-space: inherit;">Sub OpenIE()
Dim objIE As Object
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate "URL/TEST.xlsx"
objIE.Visible = True**

'Below are the codes I generated by recording Macros & adding few codes which managed to get from Internet/GoogleOn 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
</code>
 
Last edited:

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,223,268
Messages
6,171,100
Members
452,379
Latest member
IainTru

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top