Hi together,
I am using the following code in Visual Basic to open Word or Excel
applications:
Word:
Dim w As Word.Applicatio n
w = CType(CreateObj ect("Word.appli cation"), Word.Applicatio n)
w.Application.D ocuments.Open(" test.doc")
With w.Application.S election
[... whatever ...]
End With
w.Application.A ctiveDocument.S aveAs("test2.do c")
w.Documents.Clo se()
w.quit
Excel:
Dim xlapp As Excel.Applicati on
Dim xlbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
xlapp = CType(CreateObj ect("Excel.appl ication"), Excel.Applicati on)
xlbook = CType(xlapp.Wor kbooks.Add, Excel.Workbook)
xlsheet = CType(xlbook.Wo rksheets(1), Excel.Worksheet )
with xlssheet
[... whatever ...]
end with
xlapp.quit()
Now I'm trying to do the same thing in Visual C++ (Visual Studio .net 2003).
Word:
Interop::Word:: Application* w=new Interop::Word:: ApplicationClas s();
Interop::Word:: Document* wd =new Interop::Word:: DocumentClass() ;
This starts a new instance of Word. OK.
Then I tried to open an existing document or to create a new one:
Interop::Word:: Documents::Add
w->Application->Documents->Open
but these functions ask for a lot of parameters. I've got no idea what
to use. I tried to put some "NULL" in it, but it was not working.
The same problem with Excel:
Interop::Excel: :Application* ex=new Interop::Excel: :ApplicationCla ss();
starts Excel.
But everything like this is not working:
Interop::Excel: :Workbook* wb=ex->add_NewWorkboo k();
Interop::Excel: :Workbook* wb=new Interop::Excel: :Workbook();
I spent a lot of time searching MSDN and Google, but I did not find any
good example that was working.
Thank you for tips and/or examples, Bernd
Danke für Tips und Beispiele, Bernd
--
BM Computer-Services, Bergmannstr. 66, 10961 Berlin
Webdesign, Internet, Layout und Grafik
Tel.: 030/20649400, mobil 0175/7419517, Fax: 030/20649401
Web: http://www.bmservices.de, eMail: ko*****@bmservi ces.de