ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   HELP!! Cannot set any sheets to visible (https://www.excelbanter.com/excel-programming/314783-help-cannot-set-any-sheets-visible.html)

cassidyr1[_3_]

HELP!! Cannot set any sheets to visible
 

Hello,

I hope I can explain this! Here goes -

I have a VB app that creates an xls file from a template xlt file. I
adds in some sheets into the xlt file and then perform a save as t
save the file as an xls file. Then I have some 'clever' VBA code tha
hides all of the sheets on save apart from a warning page. On open th
the workbook_open runs a macro to make all the sheets visible.

So, when I open the file in xl XP, there is no problem - i.e. the macr
runs and then the sheets are made visible, great.

The problem, is however, with excel 97!! The macro runs and sets al
the sheets using:-

ThisWorkbook.Sheets(sName).Visible = xlSheetVisible

(sName comes from a hidden sheet)

The code runs through the sheets to be made visible (held on the abov
mentioned hidden sheet) and then sets the value to be -
(xlSheetHidden). Unfortunatley it doesn't actually change the valu
AND it doesn't give any error - it just does nothing?! How can thi
be?!!

Oddly, if I can run the workbook_open event manually from the VB edito
and it all works?!

Bizarrely, if I delete the sheets that have come from my VB app, sav
and close then the macro works fine on open.

If anyone has any thoughts they would be greatly appreciated!

Thanks!!!

Richar

--
cassidyr
-----------------------------------------------------------------------
cassidyr1's Profile: http://www.excelforum.com/member.php...nfo&userid=734
View this thread: http://www.excelforum.com/showthread.php?threadid=27250


Dave Peterson[_3_]

HELP!! Cannot set any sheets to visible
 
Just a guess.

Try moving your code to a general module and renaming the procedure to
Auto_open().



cassidyr1 wrote:

Hello,

I hope I can explain this! Here goes -

I have a VB app that creates an xls file from a template xlt file. It
adds in some sheets into the xlt file and then perform a save as to
save the file as an xls file. Then I have some 'clever' VBA code that
hides all of the sheets on save apart from a warning page. On open the
the workbook_open runs a macro to make all the sheets visible.

So, when I open the file in xl XP, there is no problem - i.e. the macro
runs and then the sheets are made visible, great.

The problem, is however, with excel 97!! The macro runs and sets all
the sheets using:-

ThisWorkbook.Sheets(sName).Visible = xlSheetVisible

(sName comes from a hidden sheet)

The code runs through the sheets to be made visible (held on the above
mentioned hidden sheet) and then sets the value to be -1
(xlSheetHidden). Unfortunatley it doesn't actually change the value
AND it doesn't give any error - it just does nothing?! How can this
be?!!

Oddly, if I can run the workbook_open event manually from the VB editor
and it all works?!

Bizarrely, if I delete the sheets that have come from my VB app, save
and close then the macro works fine on open.

If anyone has any thoughts they would be greatly appreciated!

Thanks!!!

Richard

--
cassidyr1
------------------------------------------------------------------------
cassidyr1's Profile: http://www.excelforum.com/member.php...fo&userid=7349
View this thread: http://www.excelforum.com/showthread...hreadid=272507


--

Dave Peterson



All times are GMT +1. The time now is 01:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com