MS-Word & Powerpoint automation, using OLE automation [Edit]

Hello,

Here is what I need to do, from my Delphi application : starting from a MS-Word document, create a PPT presentation simply made of a series of embedded MS-Word objects. There would be 1 slide for each page of the source document (assuming same page size & orientation on both sides).

This requires to control both a WordApplication and a PowerpointApplication in parallel, and proceed basically as follows :
- in Word, open the source file
- In Powerpoint, create a new presentation
- For each page of the Word doc,
|- in Word, select from start to end of current page, then "Copy"
|- in Powerpoint, create a new slide and "Paste a Word Object"
- Save the presentation

I am not familiar at all with OLE, not with MS-Word automation. Here are my questions :

1/ Running and controlling 2 applications in parallel : does it raise particular problems ?
2/ Can this process be done silently (without actually showing Word & PPT windows) ?
3/ How to "loop on pages" in the Word document ? 
4/ Is it suitable to protect the clipboard operations (in case the user would  do other things during the process) ? How, then ?
5/ When pasting, is there a mean to control the scale factor and/or resulting size of the pasted object ?
6/ Can the same code work for all Office versions (at least XP to 2010) ?

Thanks in advance for your answers.
Kind regards,
ML
1
Michel
3/20/2012 10:18:34 AM
embarcadero.delphi.ole 598 articles. 1 followers. Follow

3 Replies
2379 Views

Similar Articles

[PageSpeed] 28
Get it on Google Play
Get it on Apple App Store

Hi,

Instead of answering all you questions in detail I suggest you just start exploring 
Word Automation with the "Service" components of Delphi where the office components 
are included. There are many examples on the web where you can find all the answers.
(look for TWordApplication, TWordDocument, Delphi) 
I didn't see a lot of PowerPoint automation examples. (I never had to do it) and most 
of the examples are for Excel, Outlook and Word.

> 1/ Running and controlling 2 applications in parallel : does it raise particular problems ?
No.
> 2/ Can this process be done silently (without actually showing Word & PPT windows) ?
Yes, you can display/show the word/PP instance or leave it hidden.
> 3/ How to "loop on pages" in the Word document ?
See web.
> 4/ Is it suitable to protect the clipboard operations (in case the user would  do other things during the process) ? How, then ?
I don't think so. The protection will then also counts for the automation.
> 5/ When pasting, is there a mean to control the scale factor and/or resulting size of the pasted object ?
With office automation you can do basically everything what you can do normally in Word and PP.
> 6/ Can the same code work for all Office versions (at least XP to 2010) ?
There are two component suites that comes with Delphi, Office XP and Office 2000 components.
You have to choose/install one of the two.

Just start!

Greets.
0
Robert
3/21/2012 2:57:21 AM
Thanks Robert, this is encouraging.
Some efforts about looping on pages in a word document (found examples are mostly in VB, and there are some tricks about var Ole arguments ...).

Still I am facing an un-anticipated issue : how to Paste-as-ole-object into the PPT slide. I did not find any "PasteSpecial" method in the PPT2000 wrapper, at any level. Just the "Shapes.AddOleObject", accepting a filename as argument, which is not my need.

How to paste a MS-Word selection, as a Word object, into a PPT slide ?

Oops, I found that possibility in the PPTXP wrapper. Does anyone know if there is a turnaround to this lack in PPT2000 ?

Thanks in advance,
ML

Edited by: Michel Lefebvre on Mar 22, 2012 5:23 AM
0
Michel
3/22/2012 12:25:17 PM
Hi,

Maybe you can consider to take another route:

https://msmvps.com/blogs/tohlz/archive/2006/06/18/send-word-to-powerpoint.aspx

So, take the Word document and make it in a proper formatting.
Open PPT and load (import) the Word document in PPT..
If objects don't convert, consider to do a pdf step in between.

greets.
0
Robert
3/22/2012 2:45:37 PM
Reply:

Similar Artilces:

OLE Automation with Delphi and MS Word [Edit]
Hi, I'm working with Delphi for a while now, but it's the first time that I need to export in Word some data taken from a sqlite database. With SQLite there are no problems, everything works as it should. With Word, also because of the lack of good part of documentation, I'm currently having troubles, in particular, in the moment when i go to split a cell of a table, depending on the number of occurrences found with a SQLite query (1 occurrence = do nothing, 2 occurrences = split the cell into two rows, 15 occurrences = split the cell into 15 rows and so on). When i create ...

OLE Automation with Delphi and MS Word
Hi, I'm working with Delphi for a while now, but it's the first time that I need to export in Word some data taken from a sqlite database. With SQLite there are no problems, everything works as it should. With Word, also because of the lack of good part of documentation, I'm currently having troubles, in particular, in the moment when i go to split a cell of a table, depending on the number of occurrences found with a SQLite query (1 occurrence = do nothing, 2 occurrences = split the cell into two rows, 15 occurrences = split the cell into 15 rows and so on). When i create ...

Using OLE Automation with Word 8
We're working on converting an application that uses Word.Basic OLE Automation with Word 7 to use Word.Application OLE Automation with Word 8. We've applied the 5.0.03 patches. For some reason, we can open a document, but we can't save or saveas. The following script is being used: long i string ls_filename, ls_test_filename integer li_contact_id setpointer(hourglass!) //retrieve datawindow dw_quote_rpt.retrieve(dw_1.getitemnumber(1, "quotejob_id")) //create ole object and connect to MSWord iole_quote = create oleobject if iole_quote.connecttonewobj...

OLE Automation and MS Word
In evaluating the feasibility of using PB for an application that will use OLE Automation to interface with MS Word, I wrote some exploratory code to determine how efective PB would be as a 'driver' for OLE automation. I have a really simple test application that contains the following snippet of code: integer li_count string ls_bookmark li_count = iole_worddoc.CountBookmarks ls_bookmark = iole_worddoc.bookmarkname(1) ls_bookmark = iole_worddoc.bookmarkname(2) The first line executes in less then 1/2 second. The second line take...

Word automation - PrintOut
We're migrating our system from Delphi 7 to Delphi XE 2 and have encountered a problem when using Word Automation to print customer letters. In this case our Delphi 7 solution works happily on Windows 7 32 bit, but the same code raises an OLE exception when compiled in Delphi XE 2. Essentially we present the user with the standard print dialogue then issue the printout command. At this point we get an OLE exception. Dlg := WPObject.Dialogs.Item(88); WPObject.PrintOut(Background := false, range := dlg.Range, From := dlg.Fro...

WORD OLE automation
The following code works perfectly with WORD6/Windows95/PB6, but does not work for WORD 97/NT. OLEObject lole_word string ls_mytext = "Trial text" li_rc = lole_word = CREATE OLEObject li_rc = lole_word.ConnectToNewObject("word.basic") // in NT WORD is opened INVISIBLY // It appears as a process in the Task Manager // li_rc = 0 li_rc = lole_word.FileNew("normal", 0) // Returns li_rc = NULL li_rc = lole_word.Insert(ls_mytext) // Not recognised by WORD97 li_rc = ...

Word OLE automation
I am about to embark on a PB 5.0 project that will require dynamic creation of documents for use with Word 97's mail merge capability. Being that this is my first time using OLE, as well as my first time programming Word, could anybody point me in the right direction (books, articles, web sites, etc.) to get me started? I've experimented a little with what I could find on Microsoft's and Sybase's sites, but I am looking for something more comprehensive. =============== Daniel Buki Software Developer Butte County (CA) Migrant Education cerkit@ncal.net In article...

Word OLE automation
Would like to open word document using OLE after populating word using OLE Automation. The document should open up in print preview mode,and then using either VBA, or other code print or close from print preview. I want to supress all menus and commandbars from the word document. What code can i run from PB script to open in print preview and turn off menus and command bars, and put in two of my own command buttons. ...

WordPerfect: OLE automation through OLE control
OK, I connected to WordPerfect from PB6.5 by using OLEObject like: OLEObject ole_obj ole_obj= CREATE OLEobject li_rc=ole_obj.ConnectToNewObject ("WordPerfect.PerfectScript") ........ Now it accepts automation commands. But my goal is to start OLE automation through Object property of OLE control. Something like: ole_1.Activate(Offsite!) ole_obj=ole_1.Object.WordPerfect.PerfectScript ..... And that does not work though it does with Word. Does somebody know if it is possible at all to make OLE automation through OLE control and how to do that? Thanks ...

Word 2010 OLE automation
Hello there I user Delphi 2010 with Office 2010. When i try to open word document from my delphi application it open the file but the word stayes minimized. this is my code: procedure OpenOleWordFile(Var MsWord:Variant;WordFileName:String); Var WordDoc,Mdoc:Variant; begin try MsWord := GetActiveOleObject('Word.Application'); except try MsWord := CreateOleObject('Word.Application'); except ShowMessage('Error ....cannot open WORD'); exit; end; end; MsWord.Visible:=true; MsWord.Application.WindowState := 1...

OLE automation with MS Project.
Hi, Has any one done OLE automation from PB App to MSProject?? Just wondering what command set to use to manipulate MSProject elements from Powerbuilder. The MSProject VBA help and MSDN doesn't have necessary documentation. Any feed back / links would be highly appreciated. FYI - I am using PB8 and MS Project 2k. Thanks - Rich. Yes. I have just completed such a project, and it works well. You have to look at the VBA Help file. Contact me if you want more help: victora.reinhart@phs.com. Here is some sample code. // The following will automatically start MS Project...

OLE Automation with MS Project95
Hi. I'm using PB 6.0 and trying to use OLE automation with MS Project95. I can't seem to figure out the command to insert task information into Project from the PB app. I've searched almost everywhere for documentation on this, but have had no luck. I think it's supposed to be something like "ole_control.Tasks.Add("Task 1")", but that's not quite it, because it results in an application error. If anyone has had success with this, I would be so happy to hear from them so that I might be able to pick their brain. Thanks in advance. -- ...

OLE Automation with Word 7
All my users and fellow developers are on Word v7.0a (which does not work) and only I happen to have 7.0 (which works). I've tried background printing on and off in Word. The routine loops through multiple records as shown beloew. The first run through is fine. It fails on the second record at the FileOpen/FileNew. I tried adding wait loops of 10 seconds (!) after the fileprint and the fileclose - to no avail. The error is "Error calling external object function fileopen...". I tried upgrading to the latest PB5.0.04 maint release - still no dice. Does Powerb...

Word Automation through Win32::OLE
Long time lurker, first time poster...please be gentle. I am attempting to move through a directory, pull out only files of a ..fin extension (which is Word document format), save each one as .rtf (Rich Text Format). I'd also like to be able to run some predefined macros on the files, but I thought just being able to save was a good place to start. Currently I get an error stating 'Can't call method "SaveAs" on an undefined value'. If someone could point me to some clearer text on Win32::OLE than the stuff that ASPN, CPAN and Oreilly's Win32 o...

Web resources about - MS-Word & Powerpoint automation, using OLE automation [Edit] - embarcadero.delphi.ole

Anti Powerpoint Party
Anti powerpoint party

Microsoft PowerPoint - Wikipedia, the free encyclopedia
... / July 16, 2012 ; 32 days ago ( 2012-07-16 ) 2011 (14.1.2.110505 SP1) / June 14, 2011 ; 13 months ago ( 2011-06-14 ) Microsoft PowerPoint is ...

Microsoft PowerPoint - Wikipedia, the free encyclopedia
Microsoft PowerPoint is the name of a non-free commercial software program developed by Microsoft . It was developed by Microsoft and officially ...

authorSTREAM App Brings PowerPoint Presentations To Facebook
PowerPoint presentations aren’t just for conference rooms anymore, as Facebook application authorSTREAM allows users to upload presentations ...

Upload & Share PowerPoint presentations and documents
SlideShare is the best way to share presentations, documents and professional videos. Get a free account to upload and share. Or go PRO to get ...

POLARIS Office 5 - edit Microsoft Office Word, Powerpoint, Excel documents on the App Store on iTunes ...
Get POLARIS Office 5 - edit Microsoft Office Word, Powerpoint, Excel documents on the App Store. See screenshots and ratings, and read customer ...

Portrait with PowerPoint, after Pieter Jansz van Asch - Flickr - Photo Sharing!
Portrait with PowerPoint, after Pieter Jansz van Asch - Flickr - Photo Sharing!

How to Give an Awesome (PowerPoint) Presentation (Whiteboard Animation Explainer Video). - YouTube
An effort to eliminate "death by PowerPoint." If you liked the video, please consider liking us on Facebook. http://facebook.com/WienotFilms ...

PowerPoint should be banned. This PowerPoint presentation explains why.
It's tempting to use but many say PowerPoint can dumb things down too far, sometimes with fatal consequences.

Office 2016: Microsoft Sway is a Powerpoint gamechanger
POWERPOINT might be included in Office 2016, but everyone knows it’s so passé.

Resources last updated: 12/31/2015 4:16:33 AM