Prev | Current Page 327 | Next

David Berube

"Practical Reporting with Ruby and Rails"

Documents.add
current_selection = word_app.selection
current_selection.TypeText "Dear Mr Executive, \n"
current_selection.TypeText "I hereby resign my post as chief programmer. "
current_selection.TypeText "\n\n"
current_selection.TypeText "Sincerely,\n"
current_selection.TypeText "Mr. T. Tom\n"
word_document.SaveAs 'resignation_letter.doc'
If you run the code in Listing 12-1, you will see a screen similar to Figure 12-1.
The TypeText method in Listing 12-1 adds text to the resignation letter. You can
find out more about this method at http://msdn2.microsoft.com/en-us/library/
6b9478cs(VS.80).aspx.
A huge amount of other options are available through Win32OLE. For example, if you
add the line word_app.PrintOut to the end of Listing 12-1, it will print the document before
quitting. You can find out how to do virtually any kind of Object Linking and Embedding
(OLE) Microsoft Office automation through the Microsoft Developer Network (MSDN)
documentation.
You don??™t always need to use Win32OLE directly to control Microsoft Office programs.


Pages:
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339
AC/DC poker wygrać meble drewniane prezenty Abs