Robb or anyone


Posted by RoB on August 15, 2001 10:14 AM

This is a reply to message 27019 down a bit.

Thanks for your code, it works great, but only for the first sheet, how do I make it apply to all sheets in the workbook? Also, can you explain what this line of code does:

Worksheets("Comm2001").Outline.ShowLevels rowlevels:=1

Thanks,
Rob



Posted by Robb on August 15, 2001 3:41 PM

Rob

DisplayOutline works on the ActiveWindow so you need to set it for each worksheet:

Workbooks("whatever.xls").Worksheets("sheet1").Activate
ActiveWindow.DisplayOutline = False
Workbooks("whatever.xls").Worksheets("sheet2").Activate
ActiveWindow.DisplayOutline = False

If it does apply to every sheet in the workbook, you could use:

For Each s In Workbooks("whatever.xls").Sheets
s.Activate
s.Outline.ShowLevels rowlevels:=1
ActiveWindow.DisplayOutline = False
Next s

Setting RowLevel to 1 each time ensures all the levels are closed - in other words, if you look at a sheet with the outline symbols showing and click 1, they should all contract., this does the same.

Does this help?

Regards