Imports System.IO
Imports Microsoft.Office.Tools.Ribbon
Public Class Ribbon1
Private Sub Ribbon1_Load(ByVal sender As System.Object, ByVal e As RibbonUIEventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(sender As Object, e As RibbonControlEventArgs) Handles Button1.Click
Dim strBasePath As String = System.AppDomain.CurrentDomain.BaseDirectory
System.Diagnostics.Process.Start(strBasePath)
End Sub
End Class
2010/07/11 – It is very similar to deployinga desktop application, but not identical. With all typesof ClickOnce deployments, you may include resources that you need to access programmatically. Files with a file extensionof .xml, .mdf, and …
How do I programmatically find the deployed files for a VSTO Add-In?
You can use ClickOnce deployment to install Office Add-ins for Office 2007 and Office 2010. It is very similar to deploying a desktop application, but not identical. With all types of ClickOnce deployments, you may include resources that you need to access programmatically.
Files with a file extension of .xml, .mdf, and .mdb are assumed to be data and are deployed by default to the ApplicationDeployment.CurrentDeployment.DataDirectory, but non-data files will be found in the folder with the deployed assemblies.
省略
Here’s the code in VB:
'Get the assembly information
Dim assemblyInfo As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
'Location is where the assembly is run from
Dim assemblyLocation As String = assemblyInfo.Location
'CodeBase is the location of the ClickOnce deployment files
Dim uriCodeBase As Uri = New Uri(assemblyInfo.CodeBase)
Dim ClickOnceLocation As String = Path.GetDirectoryName(uriCodeBase.LocalPath.ToString())
省略
つまりまあ、英語の下手なワテの解釈では、この下線部分の意味は、
拡張子 .xml, .mdf, .mdb のファイルはデータと見なされて、その配布先フォルダは
ApplicationDeployment.CurrentDeployment.DataDirectory ①
Private Sub Button2_Click(sender As Object, e As RibbonControlEventArgs) Handles Button2.Click
Try
' Imports System.Deployment.Application が必要
Dim DataDirectory As String = System.Deployment.Application.ApplicationDeployment.CurrentDeployment.DataDirectory
System.Diagnostics.Process.Start(DataDirectory)
Catch ex As Exception
MsgBox(
Prompt:="exの中身:" & ex.ToString(),
Buttons:=MsgBoxStyle.OkOnly Or MsgBoxStyle.Exclamation,
Title:="なんやエラーしたぞ"
)
End Try
End Sub
コメント
wareko様、こんにちは!
本件では、ご尽力を頂き、深く感謝申し上げます。
以下のコメントの通り、解決致しました。
https://www.wareko.jp/blog/publish-excel-vsto-add-in-to-another-pc-3of10#comment-6607
心より御礼申し上げます。m(__)m
今後ともどうぞよろしくお願い申し上げます。