Click here to Skip to main content
15,909,822 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: need help in c++ inheritance.. Pin
toxcct6-May-07 23:46
toxcct6-May-07 23:46 
GeneralRe: need help in c++ inheritance.. Pin
killthecherry6-May-07 23:55
killthecherry6-May-07 23:55 
GeneralRe: need help in c++ inheritance.. Pin
toxcct6-May-07 23:59
toxcct6-May-07 23:59 
GeneralRe: need help in c++ inheritance.. Pin
killthecherry7-May-07 0:03
killthecherry7-May-07 0:03 
JokeRe: need help in c++ inheritance.. Pin
toxcct7-May-07 0:07
toxcct7-May-07 0:07 
GeneralRe: need help in c++ inheritance.. Pin
Mark Salsbery7-May-07 5:26
Mark Salsbery7-May-07 5:26 
AnswerRe: need help in c++ inheritance.. Pin
ThatsAlok16-May-07 19:57
ThatsAlok16-May-07 19:57 
QuestionProblem with opening a document which is allready open in automation? Pin
Banks K6-May-07 22:25
Banks K6-May-07 22:25 
Hello All,

I am trying to automate a word document for saving programatically so for that i am trying as follows:

first i am loading the document as follows after that i am unable to save document which is modified so how can i do that if anybody have idea about that please share with me.

i am giving the code for loading the document it is correctly working also code for saving but it is not saving that document:

int CAutoWord::InitAutomation()
{
// Get the CLSID for Word's Application Object
CLSID clsid;
CLSIDFromProgID(L"Word.Application", &clsid);

// Create an instance of the Word application and obtain the pointer
// to the application's IUnknown interface
IUnknown* pUnk;
HRESULT hr = ::CoCreateInstance( clsid, NULL, CLSCTX_LOCAL_SERVER, IID_IUnknown, (void**) &pUnk);
if (FAILED(hr))
{
OutputDebugString("Error in creating Word application instance\n");
Destroy();
return -1;
}

// Query IUnknown to retrieve a pointer to the IDispatch interface
hr = pUnk->QueryInterface(IID_IDispatch, (void**)&m_pDispApp);

// Get pointer to Documents interface.


DISPPARAMS dp = { NULL, NULL, 0, 0 };
DISPID dispID;
LPOLESTR szDoc = L"Documents";
IDispatch* pDocuments = NULL;
VARIANT varRetVal;
hr = m_pDispApp->GetIDsOfNames(IID_NULL, &szDoc, 1, LOCALE_SYSTEM_DEFAULT, &dispID);
hr = m_pDispApp->Invoke(dispID, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYGET, &dp, &varRetVal, NULL, NULL);
if (!SUCCEEDED(hr))
{
Destroy();
return -1;
}

// keep the Dispatch pointer in the member variable for later use.
m_pDocuments = varRetVal.pdispVal;

return 0;
}
int CAutoWord::SaveDocument()
{

VARIANT varRetVal;
EXCEPINFO excepInfo;
VARIANTARG varg;
varg.vt = VT_BSTR;
varg.bstrVal = _bstr_t("c:\\doc1.doc"); // this is the MS-word document filename, must be changed to a valid filename that exists on disk
DISPPARAMS dpSave = { &varg, NULL, 1, 0 };

DISPID dispSaveID;
LPOLESTR szSaveDoc = L"Save";
HRESULT hr = m_pDocuments->GetIDsOfNames(IID_NULL, &szSaveDoc, 1, LOCALE_SYSTEM_DEFAULT, &dispSaveID);
hr = m_pDocuments->Invoke(dispSaveID, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD, &dpSave, &varRetVal, &excepInfo, NULL);
printf("hello2\n");
if (FAILED(hr))
{
OutputDebugString("The document could not be printed\n");
Destroy();
return -1;
}
}

Questiononsize() flickering issue Pin
nathan76-May-07 22:16
nathan76-May-07 22:16 
AnswerRe: onsize() flickering issue Pin
baerten6-May-07 22:35
baerten6-May-07 22:35 
GeneralRe: onsize() flickering issue Pin
nathan76-May-07 23:34
nathan76-May-07 23:34 
GeneralRe: onsize() flickering issue Pin
baerten7-May-07 0:05
baerten7-May-07 0:05 
AnswerRe: onsize() flickering issue Pin
ThatsAlok16-May-07 19:56
ThatsAlok16-May-07 19:56 
QuestionTooltip text in CFormView Pin
ledallam6-May-07 22:04
ledallam6-May-07 22:04 
AnswerRe: Tooltip text in CFormView Pin
Hamid_RT7-May-07 8:57
Hamid_RT7-May-07 8:57 
Questionabout Parallel Port Pin
mt_samiei6-May-07 22:00
mt_samiei6-May-07 22:00 
AnswerRe: about Parallel Port Pin
JudyL_MD7-May-07 3:15
JudyL_MD7-May-07 3:15 
QuestionGetDCEx always returns NULL Pin
Kier Dugan6-May-07 21:54
Kier Dugan6-May-07 21:54 
AnswerRe: GetDCEx always returns NULL PinPopular
Hans Dietrich8-May-07 3:41
mentorHans Dietrich8-May-07 3:41 
QuestionAPI to remove temporary internet files Pin
Mushtaque Nizamani6-May-07 21:48
Mushtaque Nizamani6-May-07 21:48 
AnswerRe: API to remove temporary internet files Pin
_AnsHUMAN_ 6-May-07 22:02
_AnsHUMAN_ 6-May-07 22:02 
QuestionDraw textboxes with double buffering Pin
baerten6-May-07 21:36
baerten6-May-07 21:36 
QuestionRe: Draw textboxes with double buffering Pin
Hamid_RT7-May-07 8:49
Hamid_RT7-May-07 8:49 
AnswerRe: Draw textboxes with double buffering Pin
baerten7-May-07 20:40
baerten7-May-07 20:40 
QuestionHow to move to previous statement in VC++ Debugging editor Pin
vc++_fragrance6-May-07 21:27
vc++_fragrance6-May-07 21:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.