D
Deleted member 1294
Guest
Các bước đầu chuẩn bị cho tạo addin xll
Bạn cần đăng nhập để thấy đa phương tiện
Link project mẫu:
Bạn cần đăng nhập để thấy link
Imports System.Runtime.InteropServices
Imports ExcelDna.Integration.CustomUI
<ComVisible(True)>'cần thiết để hiện nút bấm
Public Class Class1
Inherits ExcelRibbon'cần thiết để hiện nút bấm
'lệnh thực hiện khi nhấn nút trên ribbon
Public Sub OnButtonPressed(control As IRibbonControl)
MsgBox("Chào mừng đến với TuhocVBA.net", vbInformation)
End Sub
End Class
<CustomUI>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
xmlns:x="khaibao">
<ribbon>
<tabs>
<tab id="idtab" label="Hello">
<group idQ="x:idQ" label="TuhocVBA.net">
<button id="C1" label="clock" size="large"
imageMso="StartAfterPrevious" onAction="OnButtonPressed" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
</CustomUI>
Imports ExcelDna.Integration.CustomUI
Imports System.Runtime.InteropServices
<ComVisible(True)>
Public Class Class1
Inherits ExcelRibbon
Dim fr1 As New Form1 'biến fr1 như Form1
Public Sub OnButtonPressed(control As IRibbonControl)
fr1.ShowDialog()'show Form1
End Sub
End Class
Imports ExcelDna.Integration.CustomUI
Imports System.Runtime.InteropServices
Imports ExcelDna.Integration
<ComVisible(True)>
Public Class Class1
Inherits ExcelRibbon
Dim app, wb, ws As Object
Public Sub OnButtonPressed(control As IRibbonControl)
thongtin()
End Sub
Private Sub thongtin()
app = ExcelDnaUtil.Application 'khai bao doi tuong me cua excel
wb = app.activeworkbook
ws = app.activesheet
ws.range("A1") = "TuhocVBA.net" 'ghi gia tri toi A1 của activesheet
MsgBox(wb.name & " and " & ws.name) 'lay ten activeworkbook va activesheet.
End Sub
End Class