B
Bernd Muent
Hi together,
I am using the following code in Visual Basic to open Word or Excel
applications:
Word:
Dim w As Word.Application
w = CType(CreateObject("Word.application"), Word.Application)
w.Application.Documents.Open("test.doc")
With w.Application.Selection
[... whatever ...]
End With
w.Application.ActiveDocument.SaveAs("test2.doc")
w.Documents.Close()
w.quit
Excel:
Dim xlapp As Excel.Application
Dim xlbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
xlapp = CType(CreateObject("Excel.application"), Excel.Application)
xlbook = CType(xlapp.Workbooks.Add, Excel.Workbook)
xlsheet = CType(xlbook.Worksheets(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::ApplicationClass();
Interop::Word:
ocument* wd =new Interop::Word:
ocumentClass();
This starts a new instance of Word. OK.
Then I tried to open an existing document or to create a new one:
Interop::Word:
ocuments::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::ApplicationClass();
starts Excel.
But everything like this is not working:
Interop::Excel::Workbook* wb=ex->add_NewWorkbook();
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
I am using the following code in Visual Basic to open Word or Excel
applications:
Word:
Dim w As Word.Application
w = CType(CreateObject("Word.application"), Word.Application)
w.Application.Documents.Open("test.doc")
With w.Application.Selection
[... whatever ...]
End With
w.Application.ActiveDocument.SaveAs("test2.doc")
w.Documents.Close()
w.quit
Excel:
Dim xlapp As Excel.Application
Dim xlbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
xlapp = CType(CreateObject("Excel.application"), Excel.Application)
xlbook = CType(xlapp.Workbooks.Add, Excel.Workbook)
xlsheet = CType(xlbook.Worksheets(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::ApplicationClass();
Interop::Word:


This starts a new instance of Word. OK.
Then I tried to open an existing document or to create a new one:
Interop::Word:

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::ApplicationClass();
starts Excel.
But everything like this is not working:
Interop::Excel::Workbook* wb=ex->add_NewWorkbook();
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