Beginner Programmer needs help with Excel Automation for MFC

  • Thread starter MathMiracleWorker
  • Start date
M

MathMiracleWorker

I have been stuck all day and need help. I have an MFC application that I
would like to print results to MS Excel. I have followed the MSDN help
procedures and do not know how to even use CApplication. I have added all
possible classes from the excel library from the MFC Add Class Wizard. I
have writen this in my .h file:

CApplication myapp;

it returns on compile:

error C2146: syntax error : missing ';' before identifier 'myapp'
error C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
error C4430: missing type specifier - int assumed. Note: C++ does not
support default-int

Can someone help me please.
 
M

MathMiracleWorker

I have added the CApplication.h file to my printmanagement.h file. I then
replaced

#import "C:\\Program Files\\Microsoft Office\\Office12\\EXCEL.EXE"
no_namespace

with

#import "C:\Program Files\Common Files\Microsoft Shared\OFFICE12\mso.dll"
rename("RGB", "MSRGB")
#import "C:\Program Files\Common Files\Microsoft
Shared\VBA\VBA6\VBE6EXT.OLB" raw_interfaces_only, rename("Reference",
"ignorethis"), rename("VBE", "testVBE")
#import "C:\Program Files\Microsoft Office\OFFICE12\excel.exe"
exclude("IFont", "IPicture") rename("RGB", "ignorethis"), rename("DialogBox",
"ignorethis"), rename("VBE", "testVBE"), rename("ReplaceText",
"EReplaceText"), rename("CopyFile","ECopyFile"), rename("FindText",
"EFindText"), rename("NoPrompt", "ENoPrompt")

for each of these

#include "CApplication.h"
#include "CRange.h"
#include "CWorkbook.h"
#include "CWorkbooks.h"
#include "CWorksheet.h"
#include "CWorksheets.h"

I am now having trouble with the following errors:

crange.h(339) : warning C4003: not enough actual parameters for macro
'DialogBoxW'
crange.h(339) : error C2059: syntax error : ','

what am I doing wrong?
 

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