none
Save Excel to new file RRS feed

  • Question

  • Can someone explain how to open an existing excel file and save as a new excel file using VB.NET 2008?  I do not need to manipulate any rows in the spreadsheet - just need a very simple open and save.
    Friday, August 19, 2011 2:34 AM

Answers

  • Hi Brian205,

     

    Thanks for posting in the MSDN Forum.

     

    I think what Cindy’s said is very important for us to give a useful solution. As far as you know there exist several different version of VSTO runtime and several technic to support your goal. If you’re not able to tell us which technic you will use or you use VSTO technic to solve your issue but you’re not able to declare which VSTO runtime you will use, we will hard to show an useful solution to you.

     

    I would recommend you read the following references before you post in the VSTO forum:

    http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/063a23a6-1595-4c83-a25f-6c94658c4649 and it will make more sense if you can provide the Office version, Visual Studio version in your question post. It will help us to approach your goal easier.

     

    I this issue I suppose you will create an Excel add-in to handle you issue. The Add-in you show a button in Add-ins tab. When us click the button the current Excel file will be save as another Excel file. I create this sample via Visual Studio 2010, Office 2010, VSTO 4.0 runtime.

     

    using System;
    
    using System.Collections.Generic;
    
    using System.Linq;
    
    using System.Text;
    
    using Microsoft.Office.Tools.Ribbon;
    
    using Excel = Microsoft.Office.Interop.Excel;
    
    
    
    namespace ExcelAddIn1
    
    {
    
     public partial class Ribbon1
    
     {
    
      private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
    
      {
    
    
    
      }
    
    
    
      private void button1_Click(object sender, RibbonControlEventArgs e)
    
      {
    
       Excel.Application app = Globals.ThisAddIn.Application;
    
       Excel.Workbook wb = app.ActiveWorkbook;
    
       wb.SaveAs(@"C:*************\test.xlsx");
    
      }
    
     }
    
    }
    
    

     

    I hope it can help you.

     

    Have a good day,

     

    Tom

     

     

     


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Wednesday, August 24, 2011 7:38 AM
    Moderator

All replies

  • I think you can get detailed information and simple source on below link.

    http://msdn.microsoft.com/en-us/library/bb386180.aspx


    http://vsto.tistory.com
    Friday, August 19, 2011 2:50 AM
  • Hi Brian

    The examples given in the other reply are specific for the VSTO technology. Are you using VSTO, or is this a Windows Forms app or something else?


    Cindy Meister, VSTO/Word MVP
    Friday, August 19, 2011 5:04 AM
    Moderator
  • Hi Brian205,

     

    Thanks for posting in the MSDN Forum.

     

    I think what Cindy’s said is very important for us to give a useful solution. As far as you know there exist several different version of VSTO runtime and several technic to support your goal. If you’re not able to tell us which technic you will use or you use VSTO technic to solve your issue but you’re not able to declare which VSTO runtime you will use, we will hard to show an useful solution to you.

     

    I would recommend you read the following references before you post in the VSTO forum:

    http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/063a23a6-1595-4c83-a25f-6c94658c4649 and it will make more sense if you can provide the Office version, Visual Studio version in your question post. It will help us to approach your goal easier.

     

    I this issue I suppose you will create an Excel add-in to handle you issue. The Add-in you show a button in Add-ins tab. When us click the button the current Excel file will be save as another Excel file. I create this sample via Visual Studio 2010, Office 2010, VSTO 4.0 runtime.

     

    using System;
    
    using System.Collections.Generic;
    
    using System.Linq;
    
    using System.Text;
    
    using Microsoft.Office.Tools.Ribbon;
    
    using Excel = Microsoft.Office.Interop.Excel;
    
    
    
    namespace ExcelAddIn1
    
    {
    
     public partial class Ribbon1
    
     {
    
      private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
    
      {
    
    
    
      }
    
    
    
      private void button1_Click(object sender, RibbonControlEventArgs e)
    
      {
    
       Excel.Application app = Globals.ThisAddIn.Application;
    
       Excel.Workbook wb = app.ActiveWorkbook;
    
       wb.SaveAs(@"C:*************\test.xlsx");
    
      }
    
     }
    
    }
    
    

     

    I hope it can help you.

     

    Have a good day,

     

    Tom

     

     

     


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Wednesday, August 24, 2011 7:38 AM
    Moderator