learningaddinexpress
Posts: 16
Joined: 2020-03-19
|
Working with VS 2019
Before using Add-in Express, I used to work with the Workbook_Open Event by placing the code in ThisAddIn.vb
Public Class ThisAddIn
'~~> Show hide ribbon based on whether a workbook is opened or not
Private Sub Application_WorkbookOpen(ByVal doc As Excel.Workbook) Handles Application.WorkbookOpen
If Application.Workbooks.Count > 0 Then
If Globals.Ribbons.Ribbon1.Tab1.Visible = False Then Globals.Ribbons.Ribbon1.Tab1.Visible = True
End If
End Sub
End Class
How do I do this in Add-in Express? |
|
Andrei Smolin
Add-in Express team
Posts: 18830
Joined: 2006-05-11
|
Hello (BTW, whats your-name?)
You put an Excel Events component onto the add-in module and handle its WorkbookOpen event. A Ribbon tab is controlled using an ADXRibbonTab component that you also put onto the module.
Imports Excel = Microsoft.Office.Interop.Excel
...
Private Sub AdxExcelAppEvents1_WorkbookOpen(sender As Object, hostObj As Object) Handles AdxExcelAppEvents1.WorkbookOpen
Dim doc As Excel.Workbook = CType(hostObj, Excel.Workbook)
Dim workbooks As Excel.Workbooks = ExcelApp.Workbooks
If workbooks IsNot Nothing Then
If (workbooks.Count > 0) Then
If Me.AdxRibbonTab1.Visible = False Then Me.AdxRibbonTab1.Visible = True
End If
Marshal.ReleaseComObject(workbooks) : workbooks = Nothing
End If
End Sub
Here's the test project: http://temp.add-in-express.com/support/MyAddin28-learningaddinexpress-forum.zip.
Andrei Smolin
Add-in Express Team Leader |
|
learningaddinexpress
Posts: 16
Joined: 2020-03-19
|
Thanks Andrei. That really helped. You can call me Mike. :) |
|
Andrei Smolin
Add-in Express team
Posts: 18830
Joined: 2006-05-11
|
You are welcome, Mike.
BTW, the Add-in Express manual is the PDF file in the folder {Add-in Express}\Docs on your development PC.
Pay attention to section Development Tips. We will consider renaming it to Best Practices.
Andrei Smolin
Add-in Express Team Leader |
|
learningaddinexpress
Posts: 16
Joined: 2020-03-19
|
Yes I am using that. Couldn't find certain things (Sometimes I can be really blind) in the Excel section for example what you recomended "MyAddin28.CurrentInstance.ExcelApp" in my other post. For the rest, I guess I am managing prettry well I must say. :)
Thanks Again! |
|
Andrei Smolin
Add-in Express team
Posts: 18830
Joined: 2006-05-11
|
learningaddinexpress writes:
Sometimes I can be really blind
That's not blindness, this means something is missing in the structure of the manual. If you find something you don't like or, well, anything, please let me know.
Andrei Smolin
Add-in Express Team Leader |
|