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 498789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:55:09+00:00 2026-05-13T05:55:09+00:00

Problem saving file back to SharePoint with Excel COM lib. I open the file

  • 0

Problem saving file back to SharePoint with Excel COM lib.
I open the file but it opens as ‘xlviewer.xlsx’ so I assume I need to overwrite the original file. (I removed the try/catch to do some error handling.) When I do I get this error: “Index refers beyond end of list” (error at line: 42 ‘SaveAs statement’)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Excel = Microsoft.Office.Interop.Excel;
using System.Reflection;
using System.IO;

namespace CopyInteractionIds
{
    class Program
    {
        static void Main(string[] args)
        {
            Excel.Application oApp;
            Excel._Workbook oWbFrom;
            Excel._Workbook oWbTo;
            Excel._Worksheet oWsFrom;
            Excel._Worksheet oWsTo;
            Excel.Range oRngFrom;
            Excel.Range oRngTo;

            //try
            //{
                oApp = new Excel.Application();
                oApp.Visible = true;
                Console.WriteLine("Opening source workbook");
                oWbFrom = (Excel._Workbook)(oApp.Workbooks.Open(@"path to my source wb"
                    , Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value
                    , Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value));
                Console.WriteLine("Opening edited workbook");
                oWbTo = (Excel._Workbook)(oApp.Workbooks.Open(@"https://path to my out wb"
                    , Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value
                    , Missing.Value, true, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value));
                Console.WriteLine("Copying data");
                oWsFrom = (Excel._Worksheet)oWbFrom.Worksheets.get_Item("Interaction Number Lookup");
                oWsTo = (Excel._Worksheet)oWbTo.Worksheets.get_Item("Interaction Number Lookup");
                oRngFrom = oWsFrom.get_Range("=OFFSET($A$1,0,0,COUNTA($A:$A),COUNTA($1:$1))",Missing.Value);
                oWsTo.get_Range("=OFFSET($A$1,0,0,COUNTA($A:$A),COUNTA($1:$1))", Missing.Value).Clear();
                oRngTo = oWsTo.get_Range("A1",Missing.Value);
                oRngFrom.Copy(oRngTo);
                Console.WriteLine("Saving edited file");
                oWbTo.SaveAs(@"path to out file"
                    , Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value
                    ,Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlShared, Missing.Value
                    , Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                oWbTo.Close(false,Missing.Value,Missing.Value);
                oWbFrom.Close(false, Missing.Value, Missing.Value);
                oApp.Quit();
            //}
            //catch(Exception ex)
            //{
            //    Console.WriteLine("Unable to process job: {0}",ex.Message);
            //}

        }
    }
}
  • 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-05-13T05:55:09+00:00Added an answer on May 13, 2026 at 5:55 am

    Someone else had the file open.

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

Sidebar

Ask A Question

Stats

  • Questions 354k
  • Answers 354k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You turn on spelling from the Edit menu (right at… May 14, 2026 at 8:30 am
  • Editorial Team
    Editorial Team added an answer Create a /compute resource that accepts multipart/form-data and POST your… May 14, 2026 at 8:29 am
  • Editorial Team
    Editorial Team added an answer Consider moving to DTO's for the interface between the presentation… May 14, 2026 at 8:29 am

Related Questions

I've been frustrated by this for the entire weekend, plus a day or two,
I thought I would find a solution to this problem relatively easily, but here
We have Product Backlog in an Excel Spreadsheet that we also commit to SVN,
I have a WPF application which saves its data to XML files in a
I'm saving some data using a series of NSDictionaries, stored in an NSMutableArray and

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.