Skip to content

Instantly share code, notes, and snippets.

@govert
Created August 20, 2019 09:57
Show Gist options
  • Save govert/a161bd8eaee8082d13e20a37002ebdaa to your computer and use it in GitHub Desktop.
Save govert/a161bd8eaee8082d13e20a37002ebdaa to your computer and use it in GitHub Desktop.
VB.NET Test for Google Groups question
Option Explicit On
Imports ExcelDna.Integration ' for ExcelDnaUtil, XlCall, etc
Imports System.Math
Imports System.Runtime.InteropServices ' for <ComVisible(True)>
Imports ExcelDna.Integration.CustomUI ' needed for IRibbonControl
Imports DNAIRibbonControl = ExcelDna.Integration.CustomUI.IRibbonControl ' needed for IRibbonControl
Imports Microsoft.Office.Interop
Imports Microsoft.Office.Core
Imports Microsoft.Office.Interop.Excel ' Các giao diện như Workbook, Range
Module Globals
Public ReadOnly Property Application As Application
Get
Application = ExcelDnaUtil.Application
End Get
End Property
End Module
<ComVisible(True)> Public Class MyRibbon
Inherits ExcelRibbon
Public Sub New()
End Sub
Public Sub PHANBO(control As DNAIRibbonControl)
' This action to show message box the content of name and Fullpath of Selected Excel file
Dim fD As FileDialog
Dim fullpath, namefile As String
Dim wbmain As Workbook
wbmain = Application.ActiveWorkbook
fD = Application.FileDialog(Microsoft.Office.Core.MsoFileDialogType.msoFileDialogFilePicker)
With fD
.AllowMultiSelect = False
.Title = "Ch" & ChrW(7885) & "n file k" & ChrW(7871) & "t xu" & ChrW(7845) & "t t" & ChrW(7891) & "n kho t" & ChrW(7915) & " Bravo"
.Filters.Clear()
.Filters.Add("Excel Files", "*.xlsx; *.xls")
.InitialFileName = "%USERPROFILE%\Desktop"
End With
If fD.Show() = -1 Then
fullpath = fD.SelectedItems.Item(1)
namefile = Dir(fD.SelectedItems.Item(1))
Else : Exit Sub
End If
MsgBox("File name is: " & namefile & "Fullpath is: " & fullpath & vbCrLf & "Show Report from Previous Wb:" & wbmain.Name)
End Sub
End Class
<?xml version="1.0" encoding="utf-8"?>
<DnaLibrary Name="VbTest2019 Add-In" RuntimeVersion="v4.0" xmlns="http://schemas.excel-dna.net/addin/2018/05/dnalibrary">
<ExternalLibrary Path="VbTest2019.dll" ExplicitExports="false" LoadFromBytes="true" Pack="true" IncludePdb="false" />
<CustomUI>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon>
<tabs>
<tab idMso="TabHome">
<group id="customsGroup" label="Ttttt" insertBeforeMso="GroupStyles">
<button id="customButton" label="Check "
size="large" onAction="PHANBO" imageMso="UpgradeWorkbook" screentip="Click"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
</CustomUI>
</DnaLibrary>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment