Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I create a Macro on OnActivateSheet to select default period. When I click this sheet tab, the Macro runs. But when I go into this sheet through button(another Macro), it can not runs.
Why?
sub SetDefTime
vDefYear=GetVarValue("vDefYear")
vDefMonthFmt=GetVarValue("vDefMonthFmt")
set vYear = ActiveDocument.Fields("Year")
set vMonthFmt = ActiveDocument.Fields("MonthFmt")
ActiveDocument.ClearAll
vYear.Select vDefYear
vMonthFmt.Select vDefMonthFmt
end sub
Hello John,
Are you using version 9? If so, you can add an action to your button, design -> activate sheet. Is the same exact code which is running from both macro and when clicking on tab?
Dear Miguel,
My button is also an activate sheet function, why it can't activate the sheet?
sub
v_sheet_name = .........
for i = 0 to ActiveDocument.NoOfSheets - 1
set ss= ActiveDocument.GetSheet(i)
if v_sheet_name=ss.GetProperties.Name then
Activedocument.Sheets(v_sheet_name).Activate
exit for
end if
next
end sub
Hello John,
You are probably using the Object ID ("SH01") instead of the name ("Main") so the property .Name is never matched. Apart from that, your code seem ok. Anyway, I'd suggest you to add that action instead of macros (I prevent from using macros whenever I can) to the button, If you just want to activate that tab.