A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Hi Paolo,
Thank you for your help.
I already noticed the fact mentioned in your first suggestion so I resolved my problem as follows:
- Generate all reports with groups not hidden.
- Run a VBS script that file by file closes all groups.
It looks like vbs function does not invalidate the buttons visibility and the result is the one I expected from the beginning. I know, it's not clean, but I had no better ideas.
Hope in future this issue will be resolved in order to avoid this overhead.
If of any help I add the vbs script here:
Dim ObjExcel, ObjWB, Subfolder, objFile
Set ObjExcel = CreateObject("excel.application")
Set FSO = CreateObject("Scripting.FileSystemObject")
' Open folder containing files
Set mainFolder = FSO.GetFolder("main\folder\path")
' Get list of files
Set colFiles = mainFolder.Files
Wscript.Echo "Elaborating file: "
For Each objFile in colFiles
' keep only xlsx files
If LCase(FSO.GetExtensionName(objFile.Name)) = "xlsx" Then
Wscript.Echo objFile.Name
Set ObjWB = ObjExcel.Workbooks.Open(objFile.Path)
' select worksheet
Set objWorksheet = ObjWB.Worksheets(1)
' collapse all grouped rows
objWorksheet.Outline.ShowLevels(1)
ObjWB.Save
ObjWB.Close True
End If
Next
ObjExcel.Quit
Wscript.Echo ""
Wscript.Echo "File update completed"
Set objWorksheet = Nothing
Set mainFolder = nothing
Set FSO = Nothing
Set ObjExcel = Nothing