I'm very glad to share with you the materials of learning Office automation.
http://cfx.codeplex.com/Wiki/View.aspx?title=All-In-One%20Code%20Framework%20Examples
This is a sample code project built by my team. For office automation, you can focus on these examples:
CppAutomateWord
CSAutomateWord
VBAutomateWord
CppAutomateOutlook
CSAutomateOutlook
VBAutomateOutlook
CppAutomateExcel
CSAutomateExcel
VBAutomateExcel
The samples’ names imply their meanings. They demonstrate the skeleton of automating office applications. There are currently no sample for PowerPoint automation, but I will add them soon.
Each sample has a ReadMe.txt file, where you can find the detailed doc of the sample.
If you have any feedback or suggestion for the project, please do email it to codefxf@microsoft.com. We are currently planning for the next stage of CodeFx. Your inputs will be valued.
Good morning Rudresh
Are you using MFC? I can reproduce the errors. They result from the duplication of names between the tlb generated symbols and the built-in MFC symbols. The solution is to use namespace:
Step1. Open each PowerPoint class generated by the MFC class wizard from tlb,
Step2. Replace the code
#import "C:\\Program Files\\Microsoft Office\\Office12\\MSPPT.OLB" no_namespace
with
#import "libid:2DF8D04C-5BFA-101B-BDE5-00AA0044DE52" \
rename("RGB", "MSORGB")
// [-or-]
//#import "C:\\Program Files\\Common Files\\Microsoft Shared\\OFFICE12\\MSO.DLL" \
// rename("RGB", "MSORGB")
using namespace Office;
#import "libid:0002E157-0000-0000-C000-000000000046"
// [-or-]
//#import "C:\\Program Files\\Common Files\\Microsoft Shared\\VBA\\VBA6\\VBE6EXT.OLB"
using namespace VBIDE;
#import "libid:91493440-5A91-11CF-8700-00AA0060263B"
Step3. Rebuild your application.
If you have any other questions or concerns, please feel free to tell me.
Are you using MFC? I can reproduce the errors. They result from the duplication of names between the tlb generated symbols and the built-in MFC symbols. The solution is to use namespace:
Step1. Open each PowerPoint class generated by the MFC class wizard from tlb,
Step2. Replace the code
#import "C:\\Program Files\\Microsoft Office\\Office12\\MSPPT.OLB" no_namespace
with
#import "libid:2DF8D04C-5BFA-101B-BDE5-00AA0044DE52" \
rename("RGB", "MSORGB")
// [-or-]
//#import "C:\\Program Files\\Common Files\\Microsoft Shared\\OFFICE12\\MSO.DLL" \
// rename("RGB", "MSORGB")
using namespace Office;
#import "libid:0002E157-0000-0000-C000-000000000046"
// [-or-]
//#import "C:\\Program Files\\Common Files\\Microsoft Shared\\VBA\\VBA6\\VBE6EXT.OLB"
using namespace VBIDE;
#import "libid:91493440-5A91-11CF-8700-00AA0060263B"
Step3. Rebuild your application.
If you have any other questions or concerns, please feel free to tell me.
Regards,
Jialiang Ge
联系客服