Hidden Columns in Excel Become Visible

  • Thread starter Thread starter Ashish
  • Start date Start date
A

Ashish

Hi,

There are some hidden columns in a Excel file.
When I open that excel file using below code and then perform some
operations on Excel file and then save the file back and view it, all the
original hidden columns are also being shown.
I do not want the original hidden columns to be visible.

_objExcel = CreateObject("Excel.Application")
_objExcel.displayalerts = False

_objBook = _objExcel.Workbooks.Open(Application.StartupPath & "\" &
strDestinationFileName)

_objWorksheets = _objBook.Worksheets

....

Thanks,
Ashish
 
Ashish

During the operations on the file can you not simply hide them again?

Worksheets("Sheet1").columns(1).hidden=true

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(e-mail address removed)
 
Hi, Ashish

If the original excel file has hidden columns,then your Vba Code must
like those:

_objExcel = CreateObject("Excel.Application")
_objExcel.displayalerts = False

_objBook = _objExcel.Workbooks.Open([Original Excel File(Path+Name) that
has hidden columns ])

' add some process code

_objBook.Saveas(Saved Path & "\" &strDestinationFileName) 'Create a
new excel file by Original File 's "SaveAs" method,So the Created is inherit
the Original Excel File that has hidden columns

_objBook.close
_objExcel.quit
 
Back
Top