Excel2000 / XP and PowerPoint2000 / XP implementation of internal COM plug-ins
Author: Xu Jing Zhou
Download sample source code (http://www.vchelp.net/itbookreview/view_paper.asp?paper_id=735)
Introduction
Excel2000 and PowerPoint2000 Interior COM plug-in programming implementation This article is actually the programming implementation of the internal COM plug-in in office2000> and programming implementation of internal COM plug-ins in Word2000 / XP> The continuation of the second article. Adopting the article
Implementation
Below, let's take a look at how to minimize the source code on the original basis to implement the COM plugin under an Excel2000 and PowerPoint2000, establish an engineering and other steps to operate according to the contents described in the previous article. Here, in addition to the source code described below requires a change, the source code content of other parts is basically the same as the sample source code in the previous article, generally does not need to be changed (unless you have other special needs).
First point: The import library part of the type of Type in the file will vary, and the source code can be replaced with the source code to the bottom.
l EXCEL2000:
/
/ * Import project required Office2k and Excel2k type libraries, * /
/ * The path can be set according to the installation path, Jingzhou Xu * /
/ ******************************************* /
#import "E: // Program files // microsoft office // office // mso9.dll" Rename_NameSpace ("Office")
Using namespace office;
#import "D: // Program files // Common files // microsoft shared // vba // vba6 // vbe6ext.olb" Rename_Namespace ("VBE6")
Using namespace VBE6;
// Excel import library
#import "E: // Program Files // Microsoft Office // Office // Excel9.OLB" Rename ("RGB", "RGBEX"), Rename ("Dialogbox", "DialogBoxEx"), Named_guids, Rename_NameSpace ("MSExcel) ")
Using namespace msexcel;
l PowerPoint2000:
/
/ * Import project required Office2k and PowerPoint2K type libraries, whose * /
/ * The path can be set according to the installation path, Jingzhou Xu * /
/ ******************************************* /
#import "E: // Program files // microsoft office // office // mso9.dll" Rename_NameSpace ("Office")
Using namespace office; #import "D: // program files // common files // microsoft shared // vba // vba6 // vbe6ext.olb" rename_namespace ("VBE6")
Using namespace VBE6;
// PowerPoint Import Library
#import "E: // Program files // microsoft office // office // msppt9.olb" named_guids, rename_namespace ("msppt")
Using namespace msppt;
Second point: Registration type information is different (* .RGS), modify the second half of the content in the file RGS as follows:
l EXCEL2000:
HKCU
{
Software
{
Microsoft
{
Office
{
Excel
{
Addins
{
'Exceladdin.excel2000Addin'
{
Val friendlyname = s 'Excel20002000 Addin'
Val Description = S 'Excel20002000 Plugin'
Val loadbehavior = d '00000003'
Val CommandLinesAfe = D '00000001'
}
}
}
}
}
}
}
l PowerPoint2000:
HKCU
{
Software
{
Microsoft
{
Office
{
PowerPoint
{
Addins
{
'Pptaddin.powerpoint2000Addin'
{
Val FriendlyName = S 'PowerPoint2000 Addin'
Val Description = S 'PowerPoint2000 Plugin'
Val loadbehavior = d '00000003'
Val CommandLinesAfe = D '00000001'
}
}
}
}
}
}
}
Third point: There is no ActiveExplorer object in Excel2000 and PowerPoint2000, so you don't have to get COMMANDBARS again, you can use the CommandBars object from _application. The modification section is shown in the following source code:
l EXCEL2000:
// Treatment when installing the plugin
StdMethod (iDispatch * Application, EXT_CONNECTMODE CONNECTMODE, IDISPATCH * AddInSt, SafeArray * * Custom)
{
CComptr
// Excel application interface _application
CCOMQIPTR
Atlassert (SPAPP);
/ / Get the CommandBars interface
HRESULT HR = SPAPP-> Get_Commandbars (& spcmdbars);
IF (Failed (HR))
Return HR;
Atlassert (spcmdbars);
// ......
}
l PowerPoint2000:
// Treatment when installing the plugin
StdMethod (iDispatch * Application, EXT_CONNECTMODE CONNECTMODE, IDISPATCH * AddInSt, SafeArray * * Custom)
{
CComptr
// Word application interface _application
CCOMQIPTR
Atlassert (SPAPP);
/ / Get the CommandBars interface
HRESULT HR = SPAPP-> Get_Commandbars (& spcmdbars);
IF (Failed (HR))
Return HR;
Atlassert (spcmdbars);
// ......
}
Ok, the Excel2000, PowerPoint2000, Word2000 and Outlook2000's internal COM plug-in implementation is mainly these, the details of the specific implementation can refer to the sample source code accompanying several articles, which has detailed notes.
references:
Programming Implementation of Internal COM Plugins under Office2000 - Xu Jinghou (Translator)
Programming Implementation of internal COM plugins in Word2000 / XP - Xu Jingzhou
ATL Development Guide (Second Edition) - Tom Armstrong & Ron Patton
Contact information:
Editor Email: jingzhou_xu@163.com
Future Studio (Future Studio)