Thomas Bach
Guest
|
Hi,
in my project, i have some functions to create individual folders in outlook. The same project should work with other office programs.
When i call the function to create the folders, but another Program is running like excel, i got an error. I treid to check the calling program in the AddinInitlaize Event, but it does?nt work. Is there any way to determine, which program is running and calling some functions by initializing depending the running program?
Regards
Thomas |
|
Dmitry Kostochko
Add-in Express team
Posts: 2875
Joined: 2004-04-05
|
Hi Thomas,
The ADXAddinModule class has several properties that you can use to get detailed information about a host application. Please see the HostType and HostName properties, the HostVersion, HostMajorVersion and HostBitness properties can also be useful. |
|
Henri Pellemans
Guest
|
You can find some useful information about checking running processes at: http://xldennis.wordpress.com/2007/11/25/access-running-instances-of-excel-in-vb/
However this info is not about ADX. A few weeks ago I developed the following code:
Private Sub AdxRibbonButton1_OnClick(sender As System.Object,
X control As AddinExpress.MSO.IRibbonControl,
X pressed As System.Boolean) Handles AdxRibbonButton1.OnClick
'ADX COM add-in for Excel Outlook and Word
Try
If Me.HostApplication Is OutlookApp Then
MessageBox.Show("button pressed in Outlook")
End If
Catch ex As Exception
MessageBox.Show("pressed in other app than Outlook")
End Try
'check if Excel is running
'for other apps see task manager for exact names:
'EXCEL, WINWORD, OUTLOOK, Acrobat etc...
Dim isExcelRunning As Boolean = isRunning("EXCEL")
If isExcelRunning Then
MessageBox.Show("Excel is running")
Else
MessageBox.Show("Excel is NOT running")
End If
End Sub
Public Shared Function isRunning(ByVal app As String) As Boolean
'Do not forget: Imports System.Diagnostics
Dim procRunning() As Process 'array to hold all processes
procRunning = Process.GetProcesses
Dim running As Boolean = False
For Each procs As Process In procRunning
If procs.ProcessName = app Then running = True
Next
Return running
End Function
|
|
Dmitry Kostochko
Add-in Express team
Posts: 2875
Joined: 2004-04-05
|
Hi Henri,
Thank you for sharing your solution with other forum readers. |
|