Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Applying macro according to the selection of reports(tab)

Hi,

Can anyone help me on this....

I want to apply some set of macro according to my sheet selection...I tried to get the sheet id using Macro , but I am not able to get sheet id in a variable....

Please give me some idea to implement this...

Thanks,

Dhoulath

3 Replies
Not applicable
Author

This will populate a variable with the Active Sheet Id:

ActiveDocument.Variables("vSelSheet").SetContent ActiveDocument.GetLayout.ActiveSheetId, true


You would probably want to include this macro for the OnActiveSheet Event of each sheet.

To get other information about the Active Sheet, it's a little more work:

Sub Testor
set actSheet = ActiveDocument.ActiveSheet
set aSp = actSheet.GetProperties
ActiveDocument.Variables("vSelSheet").SetContent aSp.name, true
End Sub


Not applicable
Author

Hi NMiller,

Thanks for ur reply.....

I am trying to use this code..Can you explain me, should we declare a variable named 'vSelSheet' in the variable setting...?

I also tried your code with one msgbox with that variablel , But it showing error.....

like this,

Sub Testor
set actSheet = ActiveDocument.ActiveSheet
set aSp = actSheet.GetProperties

ActiveDocument.Variables("vSelSheet").SetContent aSp.name, true

msgbox(vSelSheet)
End Sub

Can u explain little clear......

thanks,

Dhoulath

Not applicable
Author

Hi,

Now I got the Sheet Id as u said......Thanks once again..But if I go to next sheet, its not showing that sheet id....Still that variable showing the Previous sheet ID...Please help me out.... I need it to change according to my selection...

Thanks,

Dhoulath