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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:52:23+00:00 2026-06-01T09:52:23+00:00

So, all I’m trying to do is copy over every cell from one Excel

  • 0

So, all I’m trying to do is copy over every cell from one Excel doc to another, with the intent of preventing a user to upload a file containing macros onto my server. When I run this through with a test form it asks me where to save the “Clean” document, but it appears as though no changes were made to it, except the timestamp…

object objMissing = Missing.Value;
Excel.Workbook xlDirtyWorkbook = xlDirtyApp.Workbooks.Open(strDirtyDocPath,
                                            objMissing, objMissing, objMissing,
                                            objMissing, objMissing, objTrue,
                                            objMissing, objMissing, objMissing,
                                            objMissing, objMissing, objMissing,
                                            objMissing, objMissing);
Excel.Worksheet xlDirtyWorksheet = 
      (Excel.Worksheet)xlDirtyWorkbook.Worksheets[1];

Excel.Workbook xlCleanWorkbook = xlCleanApp.Workbooks.Open(strCleanDocPath,
                                            objMissing, objMissing, objMissing,
                                            objMissing, objMissing, objTrue,
                                            objMissing, objMissing, objMissing,
                                            objMissing, objMissing, objMissing,
                                            objMissing, objMissing);
Excel.Worksheet xlCleanWorksheet = 
      (Excel.Worksheet)xlCleanWorkbook.Worksheets[1];

// -- Copy User Modifiable Range --
Excel.Range rnThisDirtyCell = xlDirtyWorksheet.get_Range("A2:L310", objMissing);
Excel.Range rnThisCleanCell = xlCleanWorksheet.get_Range("A2:L310", objMissing);

rnThisDirtyCell.Copy(rnThisCleanCell);

// -- Copy Document Meta-Data --
object dpDirtyProps;
object dpCleanProps;

dpDirtyProps = xlDirtyWorkbook.BuiltinDocumentProperties;
dpCleanProps = xlCleanWorkbook.BuiltinDocumentProperties;

dpCleanProps = dpDirtyProps;

Frankly, I’m not even certain if it’s opening the file. The workbook Identity value is null. I’m passing a valid path for both workbooks. I’m using the full path including file name in the Application.Worksheets.Open method. Is this not correct?

What am I missing? It’s not throwing any exceptions…

==================================================================================

For posterity, this is how I solved it:

Excel.Workbook xlDirtyWorkbook = xlApp.Workbooks.Open(strDirtyDocPath,
                                 objMissing, objMissing, objMissing,
                                 objMissing, objMissing, true,
                                 objMissing, objMissing, objMissing,
                                 objMissing, objMissing, objMissing,
                                 objMissing, objMissing);

Excel.Workbook xlCleanWorkbook = xlApp.Workbooks.Open(strCleanTemplatePath,
                                 objMissing, objMissing, objMissing,
                                 objMissing, objMissing, true,
                                 objMissing, objMissing, objMissing,
                                 objMissing, objMissing, objMissing,
                                 objMissing, objMissing);

for (int iIndex = 1; iIndex <= xlDirtyWorkbook.Worksheets.Count; iIndex++ )
{
    rnThisDirtyCell = xlDirtyWorkbook.Worksheets[iIndex].UsedRange;
    rnThisCleanCell = xlCleanWorkbook.Worksheets[iIndex].Range(
        rnThisDirtyCell.Address);
    rnThisDirtyCell.Copy(rnThisCleanCell);
}
  • 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-01T09:52:24+00:00Added an answer on June 1, 2026 at 9:52 am

    My issue was that I was running two instances of excel.exe, loading one workbook into each. Loading both workbooks in the same Application instance solved my problem.

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

Sidebar

Related Questions

All the articles I've found via google are either obsolete or contradict one another.
All, I am trying to create a table to receive user inputs (UGC). This
all, I am making a game in which a sprite is move from one
All I am trying to create an app that start capturing the video from
All throughout an application wherever error messages (or other user messages) are used I
All programs that I develop utilize the default Windows Design template: Besides from changing
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
All, I have the following code: $fetch = mysql_query(SELECT * FROM calendar_events where event_status='booked'
All, I'm using Facebook Connect (JS SDK) to authenticate a user to my site.
all is said in the title, I want to get from an element all

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.