Copy & Paste with Office Open XML format RRS feed

  • Question

  • I am creating an application that copies to the clipboard with Office Open XML format and pastes it to Office products.
    In Windows version of Office, I can paste by specifying Art :: GVML ClipFormat as flavor, but can not work in Mac version of Office. I think that it is necessry to change string of flavor. what flavor should I specify for the Mac version?
    Wednesday, April 18, 2018 5:34 AM

All replies

  • What code are you using to Paste?

    How do you need to insert the clipboard data? Are you basically doing something like Selection.InsertXML (Word 2016 only) with a document coded in flat OPC OOXML format?

    If you are using VBA and PasteSpecial, it is not obvious how to use anything other than the relevant predefined values for the DataType parameter (e.g. 1 for an RTF paste).

    You can find out the class names of objects in the clipboards by executing the following command in the Applescript editor

    clipboard info

    or the following command in the Word VBE immediate Window

    ?Macscript("clipboard info as text")

    But then you do not seem to be able to use the class name in the DataType parameter. Here, although I though you might be able to retrieve the data for a given class using e.g. Macscript("get clipboard as Unicode text") it does not appear to work.

    What does Word insert if you just paste the data? Does it insert the correct, valid, XML? If so, you might be able to do something like this (you would need a reference to the MSForms library)

    Dim datobj as MSForms.DataObject
    Set datobj = new MSForms.DataObject
    Selection.InsertXML datobj.GetText
    set datobj = Nothing

    Peter Jamieson

    Wednesday, April 18, 2018 10:46 AM
  • Thank you for your reply.

    I implemented my application with Java.

    I set "Art :: GVML ClipFormat" to Clipboard format as follows.

            String flavorName = "Art::GVML ClipFormat";
            DataFlavor flavor = new DataFlavor(GvmlPorter.class, flavorName) {

    In windows I can copy something in my application and paste it to Word, Excel and PowerPoint.

    In macOS I could copy & paste when I set "—GVML-ClipFormat" to Clipboard format before.

    But now I can't.

    Could you tell me what I should do for this?

    Thursday, April 19, 2018 5:46 AM
  • It would take me some time to replicate your steps in Java.

    The best I can suggest for now is to find a way to inspect the clipboard more closely than my Applescript suggestion allows.

    For example, yu can download a clipboard viewer application from and build it and run it in Xcode. It provides more information about the clipboard contents.

    Peter Jamieson

    Thursday, April 19, 2018 7:52 AM