+ Reply to Thread
Results 1 to 2 of 2

Method 'Open' of object 'Workbooks' failed from within browser window

Hybrid View

  1. #1
    Registered User
    Join Date
    06-02-2008
    Posts
    5

    Method 'Open' of object 'Workbooks' failed from within browser window

    hi all,

    I've got an excel Macro in one of my projects that has to retrieve data from a seperate excel spreadsheet on the web. below is the code I use to extract that data:

    Sub CopyWsFromWeb()
    
        Dim wbkMsg As Workbook
        Dim Wb As Workbook
        Dim Ws As Worksheet
        
    
        With Application
            ' Turn off screen-updating and disable the canceling the procedure
            ' while the internet connection is being made
            .EnableEvents = False
            .ScreenUpdating = False
            .EnableCancelKey = xlDisabled
            ' save the current state
            Set Wb = .ActiveWorkbook
            Set Ws = .ActiveWorkbook.ActiveSheet
            ' Delete the info if it already exists
            On Error Resume Next
            .DisplayAlerts = False
            .Sheets("Info").Delete
            .DisplayAlerts = True
            On Error GoTo ErrorProcedure
            ' Opens an Excel file on the internet
            Set wbkMsg = Application.Workbooks.Open("http://location-here")
            
            ' Copy the worksheet into the current workbook
            wbkMsg.Worksheets(1).Copy After:=Wb.Worksheets(Wb.Worksheets.Count)
            ' Rename the new worksheet
            ActiveWindow.ActiveSheet.Name = "Info"
            ' Activate the original worksheet
            Ws.Activate
            Sheets("User Information").PopulateDetails
            ' Close the web workbook
            wbkMsg.Close savechanges:=False
            Sheets("Info").Visible = False
            Sheets("Details").Range("sheetDate").Value = Now
            ' re-enable screen update and canceling
            .EnableCancelKey = xlInterrupt
            .ScreenUpdating = True
            .EnableEvents = True
            
        End With
        Exit Sub
    
    ErrorProcedure:
        MsgBox Err.Description
        Application.ScreenUpdating = True
        Application.EnableCancelKey = xlInterrupt
        Application.EnableEvents = True
    End Sub
    This code works perfectly when it runs in Excel 2003, but when a link to the workbook was put on a webpage, it runs from within an Internet Explorer browser window, and this macro dies with error message "Method 'Open' of object 'Workbooks' failed".

    Is this a shortcoming of running Excel from within a browser window? Is there a workaround for this?

    thanks for any help you can give

  2. #2
    Registered User
    Join Date
    06-02-2008
    Posts
    5
    I've made the error message display a more useful message to the user, informing them that they should download the form instead of opening it in internet explorer, but this is really just a temporary solution.

    Is there no way of copying a worksheet from a location on the web from an excel workbook opened in Internet Explorer?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Store Bitmap Object In Excel 2003 To Access Database?
    By Soar in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-03-2008, 02:13 AM
  2. Activate method of chart object failed
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-30-2008, 06:37 AM
  3. Method ‘Range’ of object ‘_Global’ failed
    By The_Vulcan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-07-2007, 05:29 AM
  4. error 1004, method of class/object failed
    By daboyroy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-24-2006, 12:01 AM
  5. Replies: 3
    Last Post: 10-18-2006, 12:00 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1