Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have 5 tabs in my container. I need to find the index or the id of the chart (in a variable) for the active tab.
For exemple, If I am in the first tab, I want 1 or CH01. If I am on the second tab I want 2 or CH02.
So i use the VBScript below but vActiveIndex always give me 3 :
dim ss
set sheet = ActiveDocument.activesheet
set ss = sheet.GetProperties
select case ss.Name
case "Evolution des rémunérations"
Set ContainerObj= ActiveDocument.GetSheetObject("CT22")
end select
Set ContProp=ContainerObj.GetProperties
vActiveIndex=ContProp.SingleObjectActiveIndex
ActiveDocument.Variables("vActiveIndex").SetContent vActiveIndex, true
Do you know why the result vActiveIndex is still 3 ? Is there another solution I can workaround ?
Thank you,
Kevin
SingleObjectActiveIndex works for me. Note that the index is zero based, tab 1 is index zero and so on.
You have some code here that may confound things. What displays if you add a
msgbox vActiveIndex
Does a simple hardcoded example like this work?
Set ContainerObj = ActiveDocument.GetSheetObject("CT22")
set ContProp=ContainerObj.GetProperties
ActiveObject=ContProp.SingleObjectActiveIndex
msgbox ActiveObject
Rob,
Thank you for your answer.
I think I understand my issue. When I was in "ctrl + m" and when I tested the code, it always gave me 3 beause I was on the third index. If I change tab before test the code then it's ok, it changes the number : 0 or 1 or 2 or 3 or 4.
However, I don't know how to make the macro always active when I click on the tab. The number of the index in vActiveIndex doesn't change when I click on an other tab. It changes only when I lauch the macro. So, is it possible to do "If I click on a tab, launch the macro" ?
Kevin
You can set an OnActivateSheet trigger (Sheet Properties, Trigger) to run the macro (Actions, External, Run Macro). I've heard that OnActivateSheet triggers don't run reliably in the Ajax client, bu haven't tested recently,
-Rob
Thank you for taking the time to help me.
If I understand well, "OnActivateSheet" launch macro when I change sheet.
Do you think it would works for tab in the container ?
I don't see how to do that.
Kevin
Sorry, I misunderstood. You want to the macro to fire when you click a container tab. I don't know of any way to do that.
The workaround for the "what container tab am I on problem" is to use buttons and conditional visibility to simulate containers.
-Rob