Cyberiafreak

"Fortunate are those who take the first steps.” ― Paulo Coelho

How to create your first Office Com Addin

1) Create a C# class library project

2) Add Extensibility reference to the project
 namespace ClassLibrary1
 {
 public class Class1 : Extensibility.IDTExtensibility2

3) Implement the interface method and place a messagebox OnStartupComplete to test
4) From Project properties > Build > "Register for COM interop"
5) From Project properties > Application > Assembly information > "Make assembly COM Visible
6) Compile - VS should automatically build and register the COM to the registry
7) This would create something like this,
 Windows Registry Editor Version 5.00
   [HKEY_CLASSES_ROOT\ClassLibrary1.Class1\CLSID]
 @="{0D39F056-DF63-3860-9E79-B57F6358FD4D}"
8) Now, create the below registry file "a.reg" save and run to create this entry under HCU
For Excel, create under Excel and accordingly for other product
 Windows Registry Editor Version 5.00
 [HKEY_CURRENT_USER\Software\Microsoft\Office\Excel\Addins\ClassLibrary1.Class1]
 "LoadBehavior"=dword:00000003
Copy "{0D39F056-DF63-3860-9E79-B57F6358FD4D}" and search under HKEY_CLASS_ROOT\CLSID
Windows Registry Editor Version 5.00
 [HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{0D39F056-DF63-3860-9E79-B57F6358FD4D}]
 @="ClassLibrary1.Class1"
 [HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{0D39F056-DF63-3860-9E79-B57F6358FD4D}\Implemented Categories]
 [HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{0D39F056-DF63-3860-9E79-B57F6358FD4D}\Implemented Categories\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}]
[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{0D39F056-DF63-3860-9E79-B57F6358FD4D}\InprocServer32] @="mscoree.dll"
 "ThreadingModel"="Both"
 "Class"="ClassLibrary1.Class1"
 "Assembly"="ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
 "RuntimeVersion"="v4.0.30319"
 "CodeBase"="file:///c:/users/maheshk/documents/visual studio 2013/Projects/ClassLibrary1/ClassLibrary1/bin/Debug/ClassLibrary1.dll"
[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{0D39F056-DF63-3860-9E79-B57F6358FD4D}\InprocServer32\1.0.0.0]
 "Class"="ClassLibrary1.Class1"
 "Assembly"="ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
 "RuntimeVersion"="v4.0.30319"
 "CodeBase"="file:///c:/users/maheshk/documents/visual studio 2013/Projects/ClassLibrary1/ClassLibrary1/bin/Debug/ClassLibrary1.dll"
[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{0D39F056-DF63-3860-9E79-B57F6358FD4D}\ProgId]
@="ClassLibrary1.Class1"
9) Now launch, Excel should see the message box on load - means this add-in loaded because of load behavior set as "3" - load at start. ( at the step #8 )

10)You can check this, by Excel > File > Options > Addins > Active Application Addin: ClassLibrary1.Class, location: mscoree.dll, COM Add-in

11) Register: 
"%WINDIR%\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe" /codebase ComAddin\bin\Debug\ComAddin.dll
"%WINDIR%\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe" /unregister ComAddin\bin\Debug\ComAddin.dll

Note: You may get access denied if you did not run as VS in Admin mode. 

Refer - http://support.microsoft.com/kb/302901
Download my sample - http://1drv.ms/1GzJP1N 
Download C++ sample - http://1drv.ms/1GzK4tH
Advertisements

November 8, 2014 Posted by | .NET General, Office, Outlook | , | Leave a comment

Support guidelines for client-side messaging development – KB266353

Why Win32 API is not supported http://support.microsoft.com/kb/266353

June 14, 2014 Posted by | Outlook, Uncategorized | Leave a comment

Exchange 2010 does not support WebDAV ( discontinued)

Exchange 2007 was the last version of Exchange to support using WebDAV.

Developer roadmap for Exchange ( search for WebDAV)

http://msdn.microsoft.com/en-us/library/dd877025.aspx

Discontinued Features
http://technet.microsoft.com/en-us/library/aa998911(v=exchg.141).aspx

What may work for you is to use Exchange Web Serveries (EWS), which overall has superior calendaring abilities.  There is a .NET API called the EWS Managed API which wraps EWS calls and should make using EWS a lot easier.

Differences between the EWS Managed API and EWS

http://msdn.microsoft.com/en-us/library/office/dd633678(v=exchg.80).aspx

EWS Managed API reference

http://msdn.microsoft.com/en-us/library/office/jj220535(v=exchg.80).aspx

Microsoft Exchange Web Services Managed API 2.2

http://www.microsoft.com/en-us/download/details.aspx?id=42951

Explore the EWS Managed API 2.0

http://msdn.microsoft.com/en-us/library/office/dd633710(v=exchg.80).aspx

 

June 12, 2014 Posted by | Office, Outlook | Leave a comment

Office update center- build number and SP’s details + Open XML SDK 2.5

Open XML SDK 2.5 for Microsoft Office

http://www.microsoft.com/en-in/download/details.aspx?id=30425

Update center for Office, Office servers, and related products

http://technet.microsoft.com/en-us/office/ee748587.aspx

June 12, 2014 Posted by | Outlook | Leave a comment

How to get Outlook PST path quickly with an exe.

About GetPst.exe tool in action. Read here – http://support.microsoft.com/kb/2000021/en-us 
getpst

February 9, 2014 Posted by | Outlook | Leave a comment

Outlook:VBA#1 [How to move older mails to archive folders using code]

Private Sub Application_Startup()

Dim objOutlook As Outlook.Application
Dim objInboxFolder As Outlook.MAPIFolder
Dim myNewFolder As Outlook.Folder
Dim objNamespace As Outlook.NameSpace
Set objOutlook = Application
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objInboxFolder = objNamespace.GetDefaultFolder(olFolderInbox)
Set newFolder = objInboxFolder.Folders.Add("Test-Archived-Jan2014")
Dim movedItemCount As Long

For intCount = objInboxFolder.Items.Count To 1 Step -1
Set objVariant = objInboxFolder.Items.Item(intCount)
DoEvents
If objVariant.Class = olMail Then
intDateDiff = DateDiff("d", objVariant.SentOn, Now)
If intDateDiff > 10 Then
' Set objArchiveFolder = objNamespace.Folders("maheshk@keepmovin.com"). _
' Folders("Inbox").Folders("Old")
objVariant.Move newFolder
movedItemCount = movedItemCount + 1
Set objArchiveFolder = Nothing
End If
End If
Next
MsgBox "Done, archived:#" & movedItemCount

End Sub

January 31, 2014 Posted by | Outlook, VBA | Leave a comment

   

%d bloggers like this: