+ Reply to Thread
Results 1 to 7 of 7

Run-time error '1004': Method 'Worksheets' of object '_Global' failed

  1. #1
    Registered User
    Join Date
    10-10-2012
    Location
    Virginia, USA
    MS-Off Ver
    Excel 2003
    Posts
    12

    Run-time error '1004': Method 'Worksheets' of object '_Global' failed

    Run-time error '1004': Method 'Worksheets' of object '_Global' failed

    I get this error when running the following code:

    Please Login or Register  to view this content.
    I just want to add a sheet at the end of the workbook. This code used to work just fine with Windows XP and Office 2007. We recently updated to Windows 7 and Office 2010 and now the code breaks at the Set NWS line. Am I missing a reference somewhere? Thanks for any suggestions!
    Last edited by JSebastianRock; 02-20-2013 at 10:37 AM. Reason: SOLVED

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Run-time error '1004': Method 'Worksheets' of object '_Global' failed

    Is there more than one workbook open?

    If there is then you should add workbook references.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    10-10-2012
    Location
    Virginia, USA
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Run-time error '1004': Method 'Worksheets' of object '_Global' failed

    Quote Originally Posted by Norie View Post
    Is there more than one workbook open?
    No, there is only one open. I stored the code in Personal.xlsb, but I doubt that would matter. I tried including your code just in case, but the file is downloaded from an internet server, so the file name changes to somthing random each time.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Run-time error '1004': Method 'Worksheets' of object '_Global' failed

    There are 2 workbooks open - the personal workbook and the workbook you have downloaded/opened.

    In the code I posted try changing Workbooks("Book1.xlsm") to ActiveWorkbook.

  5. #5
    Registered User
    Join Date
    10-10-2012
    Location
    Virginia, USA
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Run-time error '1004': Method 'Worksheets' of object '_Global' failed

    Well, after I opened my eyes, I found the issue. This workbook is downloaded from an internet server, and Office 2010 uses Protected View for internet sources whereas 2007 did not. Interesting.. I just disabled that function and it works like a charm

    Capture.PNG

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Run-time error '1004': Method 'Worksheets' of object '_Global' failed

    I think Excel has always had some sort of protected view thing.

    You can change settings to disable the message and allow the file.

  7. #7
    Registered User
    Join Date
    10-10-2012
    Location
    Virginia, USA
    MS-Off Ver
    Excel 2003
    Posts
    12

    Red face Re: Run-time error '1004': Method 'Worksheets' of object '_Global' failed

    Possibly, but it never kept me from editing a downloaded file before So much for protection lol Microsoft never ceases to amaze..

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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