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

  • SEARCH
  • Home
  • 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 540k
  • Answers 540k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer We ship CDH with the Fair Share scheduler on by… May 17, 2026 at 2:39 am
  • Editorial Team
    Editorial Team added an answer I've worked through a simple database model (schema designed using… May 17, 2026 at 2:39 am
  • Editorial Team
    Editorial Team added an answer Please note that I haven't tried this. Create a workbook… May 17, 2026 at 2:39 am

Trending Tags

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

Top Members

Related Questions

I'm facing a problem when saving an UIImage, instanciated from data received from an
I am working on a Excel 2007 workbook that will contain a macro to
From the answers to this question it appears there's a file somewhere on our
Microsoft has made saving objects very easy with their LINQ to SQL mapping. However,
Problem... Since MacPerl is no longer supported on 64bit perl , I am trying
my problem : the app I have uploaded into my cellular device is shown
I work with Spring/Hibernate Dao's for saving my Object in the Database. Now I
I am trying to save drafts using NSUserDefaults but I am not sure if
I'm trying to make sure that I don't leave any loose ends open in
I feel like this will end in a facepalm moment but I've been banging

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.