Open a file in Delphi


I was wondering if there was a way to open a file (a Word file in particular) in delphi. I've built a small database application and would like the form letter to appear at the touch of a button.

Related Articles and Replies

Webmaster Guido:

From your Delphi program, you can open any file in its *associated* program. Meaning: you can start Word with a certain .DOC file, you can start NotePad with a .TXT file, and so on. If you are sure that the file type in question is "registered" with Windows -- meaning: Windows knows what program its extension belongs to -- you even don't have to provide the name of the application.

Example: most Windows systems "know" the extensions .DOC and .TXT, so in these cases it's sufficient if your program gives the command "open" and the full path of the file, and Windows will automatically start the associated application (Word, NotePad,...)

There is a mini-tutorial about opening files with their associated program and about starting external programs in DelphiLand's source code section, plus a downloadable example project. In the menu to the left, click the navigation button Code snips and look for "Running an external application".