+ Reply to Thread
Results 1 to 4 of 4

Workbook_open Event Not Working

Hybrid View

  1. #1
    Registered User
    Join Date
    10-14-2008
    Location
    Sterling, VA
    Posts
    2

    Workbook_open Event Not Working

    I have a batch file that opens a workbook that has a workbook_open event associated with it.

    When I run the batch file from a dos prompt it works fine and the workbook_open code is executed.

    However, when I run the batch file using an Runtime.exec() java function within webMethods, the behavior is different. All of the code in the batch file is executed properly, except, when the workbook is opened, the workbook_open event does not run.

    Does anybody have any ideas why the code doesn’t run?
    Last edited by mllm; 10-14-2008 at 12:41 PM. Reason: clarification

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello mllm,

    If I remember correctly MS-DOS executes the Auto_Open macro when opening a workbook. If the workbook contains a macro in the Workbook_Open() event module this will override the Auto_Open. I don't know Java, but I am guessing it, like VBA, is event driven. Check that the workbook has a macro in the Workbook_Open() event module, if there is some macro that should run when the workbook opens.

    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    10-14-2008
    Location
    Sterling, VA
    Posts
    2

    Workbook_Open Event Not Working

    Thanks for your reply Leith. I had first tried to use the auto_open macro in my spreadsheet, with the same results. I even changed the security setting to Low, so that it doesn't prompt me to enable/disable macros. I have the following code in my Workbook_open event:

    Private Sub Workbook_Open()
    
        Application.DisplayAlerts = False
        Application.EnableEvents = True
        
        Open "c:\webMethods7\IntegrationServer\packages\PricingModel\doc\TESTFILE" For Output As #1    ' Open file for output.
            Print #1, "This is a test"    ' Print text to file.
        Close #1    ' Close file.
    
        
        ActiveWorkbook.XmlMaps("PricingInputs_Map").Import URL:= _
            "C:\webMethods7\IntegrationServer\packages\PricingModel\doc\PricingModelInput.xml"
        ActiveWorkbook.XmlMaps("PricingOutputs_Map").Export URL:= _
            "C:\webMethods7\IntegrationServer\packages\PricingModel\doc\PricingModelOutput.xml"
            
        Application.Quit
    
    End Sub

    As you can see, I put a few lines in the Workbook_open event that creates a testfile, so that I can see if the event kicks off at all. To reiterate, the code runs fine when the file is opened from a command prompt. The problem is when I use a java script function to execute a command line call.

    Does workbook_open and auto_open not execute when called from a third party program? If so, is there another way to run a macro directly from the command prompt without relying on workbook_open and auto_open?
    Last edited by mllm; 10-14-2008 at 04:05 PM. Reason: Wrap [code] tags around code

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Please read the Forum Rules, and then edit your post to wrap your code with Code Tags.
    Entia non sunt multiplicanda sine necessitate

+ 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. trying to SetFocus not working
    By bhofsetz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-14-2008, 05:50 PM
  2. Run-Time Error 91 When Dynamically Creating Controls and Event Handlers
    By chucklod in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-21-2008, 05:47 PM
  3. Replies: 0
    Last Post: 04-03-2007, 09:48 AM
  4. Flagging event due dates
    By muskt in forum Excel General
    Replies: 7
    Last Post: 11-19-2006, 05:44 PM
  5. Urgent help reqd. in calculating working hours
    By prabodhkgupta in forum Excel General
    Replies: 0
    Last Post: 10-10-2006, 03:11 AM

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