|
楼主 |
发表于 2021-11-29 10:27
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
原理是一样的,VB.Net不太会,试着转了一个,运行好像没啥问题,主要代码如下,有错误还请指正,附件是VB.Net的Projiect。
- Private Sub Button1_Click(sender As Object, e As RibbonControlEventArgs) Handles Button1.Click
- Dim ExcelHWND = New IntPtr(Globals.ThisAddIn.Application.Hwnd)
- Dim thread As New Thread(Sub()
- Dim UI = New WpfWindow()
- Dim Helper = New WindowInteropHelper(UI)
- Helper.Owner = ExcelHWND
- UI.Show()
- AddHandler UI.Closed, Sub(a, b)
- UI.Dispatcher.InvokeShutdown()
- End Sub
- Dispatcher.Run()
- End Sub) With {.IsBackground = True}
- thread.SetApartmentState(ApartmentState.STA)
- thread.Start()
- End Sub
复制代码
|
|