+ Reply to Thread
Results 1 to 8 of 8

Workbooks.Open method failing to run

  1. #1
    Registered User
    Join Date
    11-29-2012
    Location
    Madison, WI
    MS-Off Ver
    MS Office 2010 (Excel, Word, Access)
    Posts
    72

    Workbooks.Open method failing to run

    I'm trying to change a subroutine that I've been using for a while into a function, so that it can be called directly rather than from a separate subroutine. Here's what I have at the moment:

    Please Login or Register  to view this content.
    The problem is that when I run the Workbooks.open method from the function, it doesn't do anything. It loads all the property data for the file into wbTelcom, but the file doesn't open up, and the object seems to refer back to ThisWorkbook instead.

    This only seems to be a problem if I enter macro processing through the function; if I use a command button that calls a standard subroutine with the method called there, it works fine. Is it some sort of problem with trying to call the method from a function? Or did I screw up the syntax somewhere?

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

    Re: Workbooks.Open method failing to run

    How exactly are you calling the function?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    11-29-2012
    Location
    Madison, WI
    MS-Off Ver
    MS Office 2010 (Excel, Word, Access)
    Posts
    72

    Re: Workbooks.Open method failing to run

    As a user-defined function from Excel. A simple '=FindCode(B2)'

  4. #4
    Registered User
    Join Date
    11-29-2012
    Location
    Madison, WI
    MS-Off Ver
    MS Office 2010 (Excel, Word, Access)
    Posts
    72

    Re: Workbooks.Open method failing to run

    Picking up on the lead you were putting there, I tried running it from the Immediate window in the editor and that did work. Still no luck with the formula being run from the worksheet though. Even if I have the workbook open from the start, it doesn't set the wbTelcom object to the appropriate reference for some reason.

  5. #5
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Workbooks.Open method failing to run

    A UDF called from a cell can't open a workbook.
    Remember what the dormouse said
    Feed your head

  6. #6
    Registered User
    Join Date
    11-29-2012
    Location
    Madison, WI
    MS-Off Ver
    MS Office 2010 (Excel, Word, Access)
    Posts
    72

    Re: Workbooks.Open method failing to run

    Ah, didn't know that.

    So, that explains why it won't open the workbook properly when I have it closed. Does the same apply to activate worksheets in other workbooks? If it does, that would explain both of my problems.

  7. #7
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Workbooks.Open method failing to run

    Yes. Why do you need to activate another sheet?

  8. #8
    Registered User
    Join Date
    11-29-2012
    Location
    Madison, WI
    MS-Off Ver
    MS Office 2010 (Excel, Word, Access)
    Posts
    72

    Re: Workbooks.Open method failing to run

    The same reason that I needed to open the workbook; my Master Inventory file is in another workbook from the worksheet where I've got the data that I'm searching for, so I need to open it and switch over in order to find the billing code used for that number.

    I'll probably just go back to the original method I was using and not worry about creating a function, at least for now.

+ 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. [SOLVED] Method 'open' of object 'workbooks' failed
    By crunchKH in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-01-2013, 09:13 PM
  2. Corrupt file. Fail to open using the workbooks.open method
    By Mortphi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-27-2013, 01:48 AM
  3. Workbooks.Open method!
    By nfuids in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-04-2011, 01:08 AM
  4. Workbooks.open method - vbs code
    By virencm in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-05-2011, 06:54 PM
  5. Workbooks.open method fails
    By JAT in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-24-2005, 05:06 PM

Tags for this Thread

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