Open An Excel Workbook From The Web And Copy It To ThisWorkbook
The code below shows how to open an Excel file on a Web server and copy the web's active worksheet to ThisWorkbook (the workbook with the code). This is useful if Excel files are stored on a Web server.
Program Code
Option Explicit Public Sub OpenWebXLS() ' ************************************************* ' Define Workbook and Worksheet Variables ' ************************************************* Dim wkbMyWorkbook As Workbook Dim wkbWebWorkbook As Workbook Dim wksWebWorkSheet As Worksheet Set wkbMyWorkbook = ActiveWorkbook ' ************************************************* ' Open The Web Workbook ' ************************************************* Workbooks.Open ("http://www.richlocus.com/Illustrations/UploadedExcel.xls") ' ************************************************* ' Set the Web Workbook and Worksheet Variables ' ************************************************* Set wkbWebWorkbook = ActiveWorkbook Set wksWebWorkSheet = ActiveSheet ' ************************************************* ' Copy The Web Worksheet To My Workbook and Rename ' ************************************************* wksWebWorkSheet.Copy After:=wkbMyWorkbook.Sheets(Sheets.Count) wkbMyWorkbook.Sheets(ActiveSheet.Name).Name = "MyNewWebSheet" ' ************************************************* ' Close the Web Workbook ' ************************************************* wkbMyWorkbook.Activate wkbWebWorkbook.Close End Sub