Word .. using drag drop to INSERT a doc file (from a Delphi app)

Posted on 2004-11-22
Last Modified: 2010-04-05
This is perhaps not quite as straightforward as it seems.

If I have a Word document (W1.doc) open, Insert|File  from the menu gives me the behaviour I want .. the contents of the specified file are inserted and all the styles (including the style "classes". those things in the drop down list under "Normal") are preserved. The inserted file becomes a seamless part of the current document (W1.doc).

So far so good. But if I drag fred.doc from say winzip (ie fred.doc is in to W1.doc then Word treats this as an "embedded" and repositionable object, sort of  like being in a frame. You can still edit that object OK, and the styles are there but ONLY in that object.. so to change a style in the embedded object you have to double click on it which opens another instance of word. This means that you cannot do global style changes across embeds.

What I would like is to be able to drag fred.doc from my app (say a database of .doc files) and have the drop in Word interpreted as an insert.

Question by:Mutley2003
    LVL 12

    Expert Comment

    if using OLE d&d then specify a rich format excluding the file format from the supported formats
    I have no clue what formats word docs support

    Author Comment

    sorry Lee, I don't follow. OK, I can set some format to "fool" Word (is that what you are saying?), but then presumably Word won't recognize the drop?
    LVL 12

    Accepted Solution

    no, word supports several 'drag' formats
    depending on the drag formats that are available from an IDataObject word desides which one to use and how
    from a file manager the data is mostly CF_HDROP in a TYMED_HGLOBAL medium
    what you can do from your app is to provide a different source format
    eg: CF_TEXT in a TYMED_ISTREAM medium (check my dragdroghelper unit from the other topic)
    this will probably result in word adding that text to the document
    now to find out how to insert the formatted document .. another chapter :)
    one way to find out what format suits word the most is to check the clipboard formats when you do a copy/paste
    I'd love to play with this but really don't have the time

    hope you'll manage :)
    LVL 2

    Expert Comment

    LVL 12

    Expert Comment

    tnx .. I'm really interested in what you've come up with

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
    In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    This video discusses moving either the default database or any database to a new volume.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now