Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8055037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:16:44+00:00 2026-06-05T08:16:44+00:00

Basically I want to create an excel management software, where clients can save their

  • 0

Basically I want to create an excel management software, where clients can save their excel files directly to the database. In order to achieve this, I’m trying to open up an excel worksheet with a certain template or file, and then let the user modify it, and when the user saves their work, it will automatically save the excel program into the database.

So what I’ve done so far is to test the event before save and it is not firing:

    static void Main()
    {
        System.Windows.Forms.Application.EnableVisualStyles();
        System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
        //Application.Run(new LoginForm());

        Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

        Microsoft.Office.Interop.Excel.Application a = new 
                              Microsoft.Office.Interop.Excel.Application();


        Workbook wb = a.Workbooks.Open("\\\\doctor-pc\\excel\\test1.xlsx", 
                  Type.Missing, false, Type.Missing, Type.Missing, Type.Missing, 
                    Type.Missing,
            Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
            Type.Missing, Type.Missing, Type.Missing);

        wb.BeforeSave += new WorkbookEvents_BeforeSaveEventHandler(wb_BeforeSave);

        a.Visible = true;

    }

    static void wb_BeforeSave(bool SaveAsUI, ref bool Cancel)
    {
        MessageBox.Show("Save");
    }

Can someone help me with this?

I cant use app level addin because I only want the behavior to affect the document opened by the program, and I can’t use document level add in because the program may open a lot of varieties of files and templates.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T08:16:46+00:00Added an answer on June 5, 2026 at 8:16 am
    1. You need to maintain a live reference to your wb variable (for example, by promoting it to a field). If the Workbook instance goes out-of-scope and gets garbage-collected, then its events would never get fired.

    2. You need to keep your .NET application open in order to be able to receive and handle the BeforeSave event. You could achieve this by creating an EventWaitHandle that blocks the Main method until signalled by wb_BeforeSave event handler.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create own filetype to save objects in my app. Basically, I
I want to create a Sub that basically allows me to target an Excel
I basically want to create an Eclipse workspace that can be accessed between accounts
Basically I want to create one large object of many object in JavaScript. Something
I have php generating html and I want to create layers. Basically I want
I want to create a Google Docs document from within Haskell, so basically I
How to create imaged scrollbars, for example: http://www.openstudio.fr/jquery/index.htm Basically, I want to create my
Basically I want to create a rock solid server. while (keepRunning.get()) { try {
Basically I want to create 48 button outlets. I have created the buttons in
Basically I want to create a method that has a signature like the following:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.