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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:39:12+00:00 2026-06-03T14:39:12+00:00

So for some purpose, I need to insert a comment in the last column

  • 0

So for some purpose, I need to insert a comment in the last column of excel.

Since I don’t want user to be able to see the comment I inserted, I try to hide the column.

Somehow it gave me an error “Cannot shift objects off sheet”

Constants.cs

HIDDEN_DATA_COL =  16384; // Which is last column in excel 2007

MyUtil.cs

Excel.Range range = ws.get_Range(ws.Cells[1, Constants.HIDDEN_DATA_COL], ws.Cells[1, Constants.HIDDEN_DATA_COL]);
 range.AddComment(result);
 range.Comment.Shape.Width = 50;
 range.Comment.Shape.Height = 50;
 range.EntireColumn.Hidden = true;

I also make some trial :

  • remove range.EntireColumn.Hidden and the code is OK.
  • changing the HIDDEN_DATA_COL to number less than 10 its also make the runtime error dissapear.

Any idea on how to fix it?

  • 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-03T14:39:14+00:00Added an answer on June 3, 2026 at 2:39 pm

    “Hiding” comments in the last column of the sheet is probably not the best way to solve your original issue.

    You faced the issue of the Cannot shift objects off sheet error within your code but even if you managed to do it, your user would face it whenever he or she would try to hide or insert any column.

    Here is how Microsoft advice to handle this: http://support.microsoft.com/kb/211769


    As this might be a case of an XY issue, I will suggest some workarounds.

    Actually, in your case, you’d probably hide your comment somewhere else, in any hidden cell for instance and if you want the user not to see it, just protect your sheet from unhiding cells.

    If you don’t want to protect, you can store your comments in another sheet and hide it with VBA using the xlVeryHidden property (user cannot unhide the sheet without VBA).

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

Sidebar

Related Questions

I need to be able to insert/update objects at a consistent rate of at
We need to implement some general-purpose object structure, much like an object in dynamic
I'm trying to write some generic structures. Essentially, what I need for my purpose
For testing purposes, I need to share some definitions between Tcl and C. Is
I'm trying to write simple proxy server for some purpose. In it I use
Best Guess: method - def(self, maybeSomeVariables); lines of code which achieve some purpose Function
For some special purpose, I modified /etc/X11/xinit/Xclients to start firefox instead of start Desktop
Is there some valid purpose to minifying before compressing? It seems highly unlikely that
Purpose: To make sure some elements couldn't be modified, I disabled some elements once
The purpose of my application is to pick some localized strings from an assembly.

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.