Problem working with MS Word through C++
Posted on 2003-11-29
Hi all !
i have the same code in C++ and VB, which just create Word instance and set it visible.
So i've tested it with many combinations of Word + Win (Win98,Me,2K,NT, XP + Word97, 2K, XP) , so C++ code sometimes work, and sometimes crashes with Exception: Server Execution Failed. Without any visible reason. There only 2 instance of Word in task manager, instead of one.
And i can't say what's combinations are wrongs, cause it can work with win98+word2K, and don't work with win2k+the same distribution of word2k. And after that it works well on win2k+ another distribution of word2k. So i'm confused :(
VB code works well everytime.
So my quetions is what's the difference between this 2 snippets of code?
And how i can write stable code for working with Word in C++?
May be i post more points, if anyone show me real stable code :)
the code here:
#import "E:\Program Files\Microsoft Office\Office\MSO9.DLL"
#import "E:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6EXT.OLB"
#import "E:\Program Files\Microsoft Office\Office\MSWORD9.OLB" rename("ExitWindows","_ExitWindows")
#import "E:\Program Files\Common Files\Microsoft Shared\DAO\DAO360.DLL" \
#import "E:\Program Files\Microsoft Office\Office\EXCEL9.OLB" \
int main(int argc, char* argv)
using namespace Word;
word->Visible = true;
"Error : %08lX\n"
"Description : %s\n"
"Source : %s\n",
Private Sub Form_Load()
Set App = New Word.Application
App.Visible = True