Thursday, April 28, 2016

Smart View - Change Alias Table(s) VB

This can either be run as a macro or 'attached' to a button on a custom ribbon (below). 

The syntax allows a change the Alias table on the current active sheet, not only a specific sheetname explicitly named i.e. "Sheet1".
Using; sheetName = ActiveSheet.Name

 Custom Ribbon button call:

Option Explicit
'Callback for rxAlias onAction
Sub rxAlias_change(control As IRibbonControl, id As String, index As Integer)
    With ActiveSheet.Cells.Interior
   
    Select Case index
Case 0
        Sample_SetALIASnone
       
Case 1
        Sample_SetALIASDefault
       

    End Select
    End With

End Sub


*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

Change Alias sub-routine:

 'Set ALIAS table(s)
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Public Declare Function HypSetAliasTable Lib "HsAddin.dll" (ByVal vtSheetName As Variant, ByVal vtAliasTableName As Variant) As Long

Sub rx_SetALIASDefault(control As IRibbonControl)
'Set ALIAS table = "Default"

    sts = HypSetAliasTable(sheetName = ActiveSheet.Name, "Default")

End Sub


Sub rx_SetALIASnone(control As IRibbonControl)
'Set ALIAS table = "none"

    sts = HypSetAliasTable(sheetName = ActiveSheet.Name, "none")

End Sub

No comments:

Post a Comment