+ Reply to Thread
Results 1 to 3 of 3

Made Private Sub in object This Workbook, now can't open workbook!

  1. #1
    Registered User
    Join Date
    07-18-2010
    Location
    Arlington, Va
    MS-Off Ver
    Excel 2007
    Posts
    6

    Made Private Sub in object This Workbook, now can't open workbook!

    So I've been trying to add a right-click menu item to my workbook. i.e. When you right-click on a cell, in addition to all the normal right-click-cell commands (copy, cut, paste, etc) there would be an additional command called "Draft Player" at the bottom of he list. It would run a macro I've defined in object Sheet1.

    I had it set up as follows:
    In object Sheet1 I had
    Please Login or Register  to view this content.

    In object "This Workbook" I had
    Please Login or Register  to view this content.
    The problem was that it didn't work. If I opened the workbook I received a "Compile Error: Sub or function not defined". This error pointed to the Private Sub Workbook_Open().

    Similarly, when I closed the workbook I received a "Compile Error: Sub or function not defined". This error pointed to the Private Sub Workbook_BeforeClose(Cancel As Boolean).

    So I thought maybe I had to move the two subs
    Sub AddToShortcut
    Sub DeleteFromShortcut

    from object: Sheet1 to object: This Workbook. Which I did. I saved and closed the workbook. Now the workbook does not open! When I double click the file name to open it, just the PERSONAL.XLSB file opens! How do I get my workbook back?!?

    I tried disabling macros to see if it would open that way, but no luck.

    Ack! Help me Obi Wan. You're my only hope!!
    Last edited by larbadar; 07-25-2010 at 02:24 PM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Made Private Sub in object This Workbook, now can't open workbook!

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    07-18-2010
    Location
    Arlington, Va
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Made Private Sub in object This Workbook, now can't open workbook!

    Hi Roy,

    Sorry, but I just had a panic attack because I thought I had lost my workbook.

    It was still there, of course, but I just couldn't view it for some reason. Turns out that it decided to "hide" itself from view. I went to View --> Unhide and bam! There it was.

    Strange, because I didn't Hide it in the first place. I wasn't aware you could even hide a workbook like that. I just figured one of my macros went haywire and decided to mess up my workbook. Ahh well. Disaster averted.



    Now I can get back to trying to figure out how to implement that right-click command I want. I will do as you suggest and post up a workbook to help others help me. But I'll do it in a separate thread, since now that I can view my workbook, this thread is now "Solved"

    Thanks Roy!

+ 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