+ Reply to Thread
Results 1 to 3 of 3

Unable to open another workbook

  1. #1
    Registered User
    Join Date
    06-03-2010
    Location
    Hertfordshire, England
    MS-Off Ver
    Excel 2010
    Posts
    51

    Unable to open another workbook

    Weird problem I hope someone can help with:

    Last few days I have created a macro (combination of recording and editing the VBA code) in Workbook A which copies a load of data from Workbook B to Workbook C. This worked (and still works) fine.

    Today I wanted to create a similar macro, this time macro in Workbook D, copying data from Workbook E to Workbook F.

    So I copied the VBA code into the new workbook D, stated to edit it by copying and modifying the bits I wanted, and putting an Exit Sub at the end of the new bit. This all worked fine for while, with data being copied into Workbook F. However, after a bit more editing I may have mistyped something and when running the macro again it seemed to get stuck in some loop and I had to terminate Excel by using the Task Manager.

    Now, when I try and step though the macro it fails when I test for the existence of Workbook E:

    Please Login or Register  to view this content.
    The file is there, in the right place, and not already open.

    I've since tried creating (recording) a test simple macro in workbook Test1, which opens workbook Test2 via windows explorer (it's in same folder as Test1) and select cell A1. The macro is recorded is:

    Please Login or Register  to view this content.
    there's just a blank line where I would have expected to see something like :
    Workbooks.Open Filename:="Test2.xls"

    If I add the line to the code and step through it and error message Run-time error '1004' file cannot be found is displayed

    and if I modify the code to:

    Please Login or Register  to view this content.
    the MsgBox does display the correct path, C:\Data and Test2.xls is definitely in there and not already open!

    I've tried rebooting the PC, no different.

    Using Office W7 Prof 64b, Office 2010, macros enabled. Using .xls format cos I need the backwards compatibility, but as said above yesterdays macros and files all still work fine.

    Can anyone help please, happy to run more tests, but this is my first time of using macros/VBA so a bit of a newbie in this area.

    Thanks.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Unable to open another workbook

    Is this solved?

    If you solve a problem yourself before anyone else has responded, please take a moment to describe your solution, chances are some other member will benefit.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    06-03-2010
    Location
    Hertfordshire, England
    MS-Off Ver
    Excel 2010
    Posts
    51

    Re: Unable to open another workbook

    Yes it's solved. After more searching on this forum I changed the test to

    Please Login or Register  to view this content.
    and this works OK. Sorry, forgot to go back and mark this solved!

+ 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. Replies: 1
    Last Post: 03-18-2013, 11:09 PM
  2. Unable to get code to run a click event on workbook open
    By taylog2 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-05-2012, 09:39 PM
  3. [SOLVED] Unable to open saved workbook
    By CVS in forum Excel General
    Replies: 4
    Last Post: 02-06-2005, 01:06 PM
  4. Replies: 0
    Last Post: 02-01-2005, 10:31 AM
  5. Workbook unable to open because "Personal.xls" already open !?
    By PropKid in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-01-2005, 10:30 AM

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