+ Reply to Thread
Results 1 to 4 of 4

Open Event Error

  1. #1
    Registered User
    Join Date
    09-15-2010
    Location
    Michigan
    MS-Off Ver
    MS Office 2007
    Posts
    2

    Open Event Error

    Greets.

    I am relatively new to the world of programming for Excel, and am working to learn the basics. I have been going off of a Excel 2003 programming tutorial, from which I have learned a fair amount. Unfortunately, there is one issue I have been unable to find a solution to.

    I am trying to get a module to execute as soon as I open this particular excel document. The following code has been written into the "ThisWorkbook" Open Event window as told to do so in the tutorial:

    Please Login or Register  to view this content.

    The modules I have built are as follows:
    Module1
    MyFirstMacro
    TimeSheets

    Every time I open the excel file, instead of executing TimeSheets, I get an error: "Compile Error: Expected variable or procedure, not module."

    I have been unable to figure out exactly why this is happening. Any thoughts to help me get through, what I assume is an incredibly basic, hurdle? I would be much obliged!
    Last edited by gumdrop; 09-15-2010 at 07:19 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Open Event Error

    1. Modules don't execute, procedures within them (Subs and Functions) do.

    2. You can't have a procedure with the same name as a module.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    09-15-2010
    Location
    Michigan
    MS-Off Ver
    MS Office 2007
    Posts
    2

    Re: Open Event Error

    For some reason, though I read this exact same statement earlier trying to troubleshoot this issue, when I read your response and then looked over what I had been doing it became suddenly clear what exactly was happening. Problem solved, moving on from that then.

    Edit: Actually, I do know the reason. Specifically mentioning that modules don't execute but rather the procedures do led me immediately to the solution.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Open Event Error

    For future reference, a better title for your thread would have been the exact error message:

    Compile Error: Expected variable or procedure, not module

+ 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