Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have an application with a number of sheets/functionality, e,g P&L, Balance Sheet, Cashflow, Open Invoices etc.
Each sheet has various views, e.g. Reports, Charts, Details, displayed when the user pressses buttons that set a variable which the various filters, charts and tables test for in the Show conditional on their Layout tab.
I have some macro code that is triggered by each of these button pushes, and when moving to a different sheet. It tests which area of functionality it being viewed and then decides how to treat the date fields shown on each sheet. The default treatment is as a tool for setting an analysis date for point-in-time measures, but then under certain conditions, such as when showing a 'Details' view, they are set to be proper date filters that reduce the data when selected.
The issue I have is that, as the same application is deployed with different sheets being visible/available, how I should test which sheet is active. I am currently conducting this test:
if ActiveDocument.Sheets(0).IsActive then .... end if
However, I want to change the SheetID on the sheet properties General tab to be a more useful identifier (PL, BS, CF etc.), and then test using this sort of code:
if ActiveDocument.Sheets("BS").IsActive then .... end if
However, when I do this it does not seem to work, bringing up the Macro editor but without saying why. Can someone advise on a better syntax ?
Jonathan
P.S: Providing a sample application would be hard, which is why I have provided so much backgound detail
This works fine for me in QV10: if activedocument.sheets("Main").isactive then msgbox "Yah!"
But if you want to know the name of the active sheet you can get it like this:
set sp = activedocument.activesheet.getproperties
msgbox sp.Name
Maybe you can work around it that way.