dlh
03-24-2010, 12:05 PM
This has to be an Excel bug. Certain columns in my file are visible when the file is closed but are hidden when it's reopened in 2003. It doesn't happen in 2007, but does happen the first time the file is reopened in 2003.
More detail: I've got a "template" sheet with a group of visible columns and, immediately to their right, a group of hidden columns (D:G visible, H:K hidden). My macro copies this set of visible & hidden columns and pastes them multiple times as a template onto another sheet. The rightmost visible columns in all these template-pastes (column G in the template) are the ones that become spontaneously hidden upon reopening the document.
I've used a debug-watch on the ColumnWidth property and verified that my code is not changing anything either on save or reopen.
I do have a solution to my problem. If I manually change one of the problem columns' widths before saving, then that column doesn't disappear. If I set a single one's ColumnWidth via code to the value it already is, then all columns don't disappear. And the problem only occurs after my copy-paste macro has been run, so there's no danger of columns re-disappearing.
ActiveSheet.Columns("P").ColumnWidth = ActiveSheet.Columns("P").ColumnWidth
Can anyone tell me anything more about this bug? Is there any way to cleanse the file so that my workaround is not necessary?
(Unfortunately this is part of a fairly complicated VBA application, which is why I haven't posted the file. If necessary, I'll try to create a stripped down version that has the problem.)
More detail: I've got a "template" sheet with a group of visible columns and, immediately to their right, a group of hidden columns (D:G visible, H:K hidden). My macro copies this set of visible & hidden columns and pastes them multiple times as a template onto another sheet. The rightmost visible columns in all these template-pastes (column G in the template) are the ones that become spontaneously hidden upon reopening the document.
I've used a debug-watch on the ColumnWidth property and verified that my code is not changing anything either on save or reopen.
I do have a solution to my problem. If I manually change one of the problem columns' widths before saving, then that column doesn't disappear. If I set a single one's ColumnWidth via code to the value it already is, then all columns don't disappear. And the problem only occurs after my copy-paste macro has been run, so there's no danger of columns re-disappearing.
ActiveSheet.Columns("P").ColumnWidth = ActiveSheet.Columns("P").ColumnWidth
Can anyone tell me anything more about this bug? Is there any way to cleanse the file so that my workaround is not necessary?
(Unfortunately this is part of a fairly complicated VBA application, which is why I haven't posted the file. If necessary, I'll try to create a stripped down version that has the problem.)