C# Outlook 2003 Add-In [installation problems]

C

Chris Bellini

Greetings!

I'm developing an add-in for Outlook 2003 (and perhaps Outlook XP as
well, but later) with C# using Visual Studio .NET 2003. I've been
following these examples:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/ol03csharp.asp

http://blogs.msdn.com/dancre/archive/2004/03/21/93712.aspx

I can get the solution to compile with no problems. However, I cannot
for the life of me get the add-in to install. I've built the MSI and
gone through the installation (which reports no errors) but when I
launch Outlook 2003, the toolbar button for my Add-in isn't created.
I've even tried to follow these suggestions to possible installation
problems:

http://www.shahine.com/omar/PermaLink,guid,ee43e226-a1e9-4077-b20c-b70602b93ea3.aspx

But to no avail. I've also written it as a stand-alone application but
almost everything disaplys the Outlook Security Warning dialog which is
why I'd like to get this to work as an Office Add-in. Any suggestions?
Thanks in advance.


Chris
 
S

sk

I don't know how msi works but do you set the registry for addin?
or maybe you just have to show the addin button going" COM Add-ins" button

tools -> customize ->commands tab -> select tools -> drag out the com button
when you click on the COM add-ins button all available addins will be shown.

When comes to installer i always use innosetup for outlook, word, excel,
powerpoint addins.
http://www.jrsoftware.org


Shinya
 
C

Chris Bellini

Well there's a slight problem with that. My COM add-in never shows up
in the list of installed add-ins. I'm just testing this on my computer
right now, before deploying it to the rest of the company. How can I
manually install it? Thanks.


Chris
 
S

sk

For my case, i created a little tool to register the dll and add necessary
parameters
to registory for office addins in VB6 Probably similar thing is available in
C# at MS website.
if you still have this problem let me know so that i can help you. If you
have actual sample code for
C# office com addin at microsoft send me the link so that i can install to
see where
is the problem.

Shinya

http://support.microsoft.com/?kbid=238228

Option Explicit

Private Declare Function RegCreateKeyEx Lib "advapi32.dll" _
Alias "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, _
ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As _
Long, ByVal samDesired As Long, ByVal lpSecurityAttributes As Long, _
phkResult As Long, lpdwDisposition As Long) As Long

Private Declare Function RegSetValueEx Lib "advapi32.dll" _
Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As _
String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, _
ByVal cbData As Long) As Long

Private Declare Function RegDeleteKey Lib "advapi32.dll" _
Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) _
As Long

Private Declare Function RegCloseKey Lib "advapi32.dll" _
(ByVal hKey As Long) As Long

Private Const HKEY_CURRENT_USER = &H80000001
Private Const KEY_ALL_ACCESS = &H1F0037
Private Const REG_CREATED_NEW_KEY = &H1
Private Const REG_SZ = 1
Private Const REG_DWORD = 4

'These are the settings for your Add-in...
Private Const PROGID As String = "MyCOMAddin.Connect"
Private Const DESCRIPTION As String = "My VB5/6 COM Add-In Sample"
Private Const LOADBEHAVIOR As Long = 3
Private Const SAFEFORCOMMANDLINE As Long = 0


Public Sub RegisterAll()
RegisterOfficeAddin "Access"
RegisterOfficeAddin "Excel"
RegisterOfficeAddin "FrontPage"
RegisterOfficeAddin "Outlook"
RegisterOfficeAddin "PowerPoint"
RegisterOfficeAddin "Word"
End Sub

Public Sub UnregisterAll()
UnRegisterOfficeAddin "Access"
UnRegisterOfficeAddin "Excel"
UnRegisterOfficeAddin "FrontPage"
UnRegisterOfficeAddin "Outlook"
UnRegisterOfficeAddin "PowerPoint"
UnRegisterOfficeAddin "Word"
End Sub

Public Sub RegisterOfficeAddin(sTargetApp As String)
Dim sRegKey As String
Dim nRet As Long, dwTmp As Long
Dim hKey As Long

sRegKey = "Software\Microsoft\Office\" & sTargetApp _
& "\Addins\" & PROGID

nRet = RegCreateKeyEx(HKEY_CURRENT_USER, sRegKey, 0, _
vbNullString, 0, KEY_ALL_ACCESS, 0, hKey, dwTmp)

If nRet = 0 Then
If dwTmp = REG_CREATED_NEW_KEY Then
Call RegSetValueEx(hKey, "FriendlyName", 0, _
REG_SZ, ByVal PROGID, Len(PROGID))
Call RegSetValueEx(hKey, "Description", 0, _
REG_SZ, ByVal DESCRIPTION, Len(DESCRIPTION))
Call RegSetValueEx(hKey, "LoadBehavior", 0, _
REG_DWORD, LOADBEHAVIOR, 4)
Call RegSetValueEx(hKey, "CommandLineSafe", 0, _
REG_DWORD, SAFEFORCOMMANDLINE, 4)
End If
Call RegCloseKey(hKey)
End If

End Sub

Public Sub UnRegisterOfficeAddin(sTargetApp As String)
Dim sRegKey As String
sRegKey = "Software\Microsoft\Office\" & sTargetApp _
& "\Addins\" & PROGID

Call RegDeleteKey(HKEY_CURRENT_USER, sRegKey)

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top