• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 213
  • Last Modified:

Linking MSWord and MSExcel with delphi

1. I want to load database fields into a MSWord document dynamically, so how do I go about doing this? Please provide example.
2. I want to load data from a MSExcel spreadsheet into the database and rows made into columns dynamically.How do I go about doing this. Please provide example.
0
mamello
Asked:
mamello
1 Solution
 
SlavakCommented:
what database? and what you mean: "dynamically"?
Is it some kind of word<-->db<-->excel convertor?
0
 
mamelloAuthor Commented:
1. I want to load database fields into a MSWord document, so how do I go about doing this?
Please provide example.
2. I want to load data from a MSExcel spreadsheet into the database and rows made into columns .How
do I go about doing this. Please provide example.
I am using interbase for the database
0
 
swift99Commented:
What database doesn't matter.

Word and Excel are both COM objects, so they can be invoked via the COM interface.

I usually write the core of the code as a VBA script and then translate it to Delphi.  This example is not guaranteed to be more than close, since I'm running on the linux side right now and can't check my Delphi help files.  However, it encapsulates the intent of what I am trying to put across.

Procedure HelloExcel;
var
    aWorksheet: Variant;
begin
    CreateObject ('ExcelNoteBook', aWorksheet);
    aWorksheet.Cells]1,1] := 'Hello, World';
    aWorkSheet.SaveAs ('Hello.xls');
    aWorksheet.Close;
end;


You can also set formulas, styles, and so on.  Use your Excel and Word online help, and remember that although the API is the same for Delphi and VBA the languages are different.  Arrays are delimited by () in VB and by [] in Delphi for example.

0
 
pnh73Commented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept answer from swift99

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Paul (pnh73)
EE Cleanup Volunteer
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now