Click here to Skip to main content
15,924,367 members
Home / Discussions / COM
   

COM

 
GeneralRe: table selection. Pin
darkbyte28-Aug-04 5:20
darkbyte28-Aug-04 5:20 
GeneralRe: table selection. Pin
Member 52815529-Aug-04 20:52
Member 52815529-Aug-04 20:52 
GeneralDifferences COM/ActiveX/Automation Pin
User 21559727-Aug-04 3:51
User 21559727-Aug-04 3:51 
GeneralRe: Differences COM/ActiveX/Automation Pin
Lim Bio Liong27-Aug-04 8:03
Lim Bio Liong27-Aug-04 8:03 
GeneralRe: Differences COM/ActiveX/Automation Pin
User 21559729-Aug-04 19:07
User 21559729-Aug-04 19:07 
GeneralRe: Differences COM/ActiveX/Automation Pin
Jörgen Sigvardsson27-Aug-04 14:13
Jörgen Sigvardsson27-Aug-04 14:13 
GeneralRe: Differences COM/ActiveX/Automation Pin
User 21559729-Aug-04 19:12
User 21559729-Aug-04 19:12 
GeneralMS Word Automation from consol App Pin
Dean Warren27-Aug-04 0:44
Dean Warren27-Aug-04 0:44 
Hi There

I am having trouble automating Word from a win32 consol application.

I have used the example given on MSDN

http://support.microsoft.com/default.aspx?scid=kb;en-us;238393

and this works nicely. That is it opens a Word Document does some stuff, saves and closes.

Unfortunetly its the 'does some stuff I am having trouble with! I want to add tables to a word document and populate with data.

My variation to the MSDN example is as follows: that is I replace the Open and go from there...
/*******************************************************************************/
/******************************* MY AUTOMATION *********************************/
/*******************************************************************************/
// Call Documents.Add() to create a document
IDispatch *pDoc;
{
VARIANT result;
VariantInit(&result);

AutoWrap(DISPATCH_METHOD, &result, pDocs, L"Add", 0);
pDoc = result.pdispVal;
}

//***Create a Table***
IDispatch *pTable;
{
VARIANT result;
VariantInit(&result);
AutoWrap(DISPATCH_PROPERTYGET, &result, pDoc, L"Tables", 0);

pTable = result.pdispVal;
}

//***Set Range to beginning of document***
IDispatch *pRange;
{
VARIANT result;
VariantInit(&result);
VARIANT varStart, varEnd;

varStart.vt = VT_I4;
varStart.lVal = 0;

varEnd.vt = VT_I4;
varEnd.lVal = 0;

AutoWrap(DISPATCH_METHOD, &result, pDoc, L"Range", 2, varEnd, varStart);
pRange = result.pdispVal;
}

//***Add table a location specified by range***
{
VARIANT result;
VariantInit(&result);

VARIANT varRange, varRows, varColumns;
varRange.vt = VT_DISPATCH;
varRange.pdispVal = pRange;

varRows.vt = VT_I4;
varRows.lVal = 0;
varColumns.vt = VT_I4;

varColumns.lVal = 0;

AutoWrap(DISPATCH_METHOD, &result, pTable, L"Add", 3, varColumns, varRows, varRange);
}

// Call Documents.SaveAs() to save a document at/as C:\myDoc.doc
{
VARIANT result;
VariantInit(&result);
VARIANT x;
x.vt = VT_BSTR;
x.bstrVal = ::SysAllocString(L"C:\\myDoc.doc");

AutoWrap(DISPATCH_METHOD, &result, pDoc, L"SaveAs", 1, x);
// pDoc = result.pdispVal;
SysFreeString(x.bstrVal);
}
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/

But it I get an error back from the IDispath raising an exception (no useful info) when AutoWrap (... "Add"...) ???

HELP!!!!! PLEASE!!!!

Regards Dean
GeneralMS Word Automation: Attempted the same thing with Visual C++ .NET Pin
ursus zeta28-Aug-04 11:24
ursus zeta28-Aug-04 11:24 
GeneralAfterword Pin
ursus zeta29-Aug-04 10:04
ursus zeta29-Aug-04 10:04 
Generaldemodulation Pin
maxuk26-Aug-04 16:08
maxuk26-Aug-04 16:08 
GeneralRe: demodulation Pin
darkbyte28-Aug-04 5:22
darkbyte28-Aug-04 5:22 
GeneralRe: demodulation Pin
maxuk29-Aug-04 3:31
maxuk29-Aug-04 3:31 
GeneralRe: demodulation Pin
Jörgen Sigvardsson28-Aug-04 11:41
Jörgen Sigvardsson28-Aug-04 11:41 
GeneralMS-WORD Addin Pin
deepha8226-Aug-04 5:16
deepha8226-Aug-04 5:16 
GeneralInterface inheritance Pin
Anonymous25-Aug-04 23:42
Anonymous25-Aug-04 23:42 
Questioncan i disable the IE File->new menu in a Activex Control(based on MFC) Pin
max_xiayi25-Aug-04 17:53
max_xiayi25-Aug-04 17:53 
Generalplz give me some sites for mshtml interfaces Pin
Member 52815524-Aug-04 20:51
Member 52815524-Aug-04 20:51 
Generalimplement pre element Pin
Member 52815524-Aug-04 19:40
Member 52815524-Aug-04 19:40 
GeneralThe server did not register with DCOM within the required timeout. Pin
sergeyv200220-Aug-04 10:16
sergeyv200220-Aug-04 10:16 
GeneralRe: The server did not register with DCOM within the required timeout. Pin
Milton Karimbekallil22-Aug-04 20:07
Milton Karimbekallil22-Aug-04 20:07 
GeneralRe: The server did not register with DCOM within the required timeout. Pin
sergeyv200223-Aug-04 3:21
sergeyv200223-Aug-04 3:21 
GeneralRe: The server did not register with DCOM within the required timeout. Pin
Milton Karimbekallil23-Aug-04 18:34
Milton Karimbekallil23-Aug-04 18:34 
GeneralGet class name from interface Pin
Anonymous19-Aug-04 9:31
Anonymous19-Aug-04 9:31 
GeneralRe: Get class name from interface Pin
Jörgen Sigvardsson19-Aug-04 14:14
Jörgen Sigvardsson19-Aug-04 14:14 

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.