Hi Friends,
 I have a problem with reading a ms word application
(97,2000), am calling a dll from java thru jni, but
while calling it shows  error at CreateDispatch
method.

Can anyone help me with a sample code, am providing
the code with which i worked see below, in the code i
have included the msword8.h and FileReader.h along
with other header files.
Thanx in advance

Ann
******************************************************
JNIEXPORT jstring JNICALL Java_mailDll_WordReader
(JNIEnv * jenv, jclass jobj, jstring jsFile)
{
        const char * chFile =
(jenv)->GetStringUTFChars(jsFile, 0);
    COleVariant vTrue((short)TRUE),
                vFalse((short)FALSE),
                vOpt((long)DISP_E_PARAMNOTFOUND,
VT_ERROR);
        HRESULT hr = CoInitialize(NULL);
    //Start a new instance of Microsoft Word
    _Application oWordApp;
    if
(!oWordApp.CreateDispatch("Word.Application.1"))//,NULL))
    {

        return (jenv)->NewStringUTF("CreateDispatch
failed.");
    }
    Documents oDocs;
    _Document oDoc;
    oDocs = oWordApp.GetDocuments();
    oDoc=oDocs.Open(COleVariant(chFile),vOpt,vOpt,
vOpt, vOpt, vOpt,vOpt, vOpt, vOpt, vOpt);
    Selection oSel;
    oSel = oWordApp.GetSelection();
    oSel.WholeStory();
        CString
chContents=oSel.GetText();//AfxMessageBox(chContents);
        oWordApp.Quit(vOpt, vOpt, vOpt);//Quit the
application
        CoUninitialize();


        return (jenv)->NewStringUTF(chContents);
}
******************************************************

____________________________________________________________
Do You Yahoo!?
Send a newsletter, share photos & files, conduct polls, organize chat events. Visit 
http://in.groups.yahoo.com

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to