This is in an IDTExtensibility2 (not VSTO) Word AddIn. I'm trying to do a drag drop where I programatically give the contents of one document to DoDragDrop(). The problem is instead of dropping the contents in the other document, it inserts it as an embedded Word document.
My code is basically:
srcDoc.Activate();
activeWindow = srcDoc.ActiveWindow;
selection = activeWindow.Selection;
selection.WholeStory();
selection.Copy();
data = Clipboard.GetDataObject();
DragDropEffects effect = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Scroll);
How can I have it paste the contents instead of pasting the document?
Please note, I want to paste all of the content in the source document into the insertion point of the drop in the destination object. So it's not copy over the full contents of the destination (therefore a file based approach won't work).
And it's drag/drop so I don't have the control that Clipboard.Paste() provides to specify the pasting format. In addition, the format I need is the native DOCX format to bring all properties & formatting across.
thanks - dave
Related
I am trying to store and high-light text copied by user when he opens the word file back. When he copies one paragraph, I am able to highlight (I am storing all this copied information for e.g. range values in an XML file) but when he copies content of multiple paragraphs using Ctrl Button, I am unable to get individual range values.
Could you guys help on this?
What you are trying to do is not supported by (the current versions of) Word because programmatic access to discontiguous selection is limited. In particular, you cannot access the different ranges in that selection (you can only the last subrange).
The limitations are listed in detail in this MSDN article:
Limited programmatic access to Word discontiguous selections
Like in MS Excel one csv file may contain more than one sheet, Like this what I have to do is I want to keep all the theory in one word file and the programs in another word file. But I want to attach these both file with each other as a single DOC file.
Like a single DOC file contain theory as well as programs, which is open as two separate content/file.
Something close to what you want to do is the following:
In new Word Document Select your "View" Tab and then Select "Outline View".
Then Select "Show Document". The "Insert Button will now be visible.
You can now insert various documents in this document.
Unfortunately as far as I know this will have links into the original Documents which you can then open, edit and access from the new document.
Try it out and let me know!
Also, you can maybe try Microsoft One Note, I think this is probably what you looking for. See partial screen shot below for an idea.
I want to automate some writer tasks. I need to create a .odt writer
document with oo:doc using methods such as create paragraph and append
paragraph. The problem is that append paragraph and create paragraph does not
allow text to start at middle of page or at a certain column, ie
Name Surname Address
When I unzip the "master" document I want to to create, when I inspect the content.xml file i see the xml equivalent is
" <text:p text:style-name="Text_20_body"><text:s text:c="115"/><text:span text:style-name="T1"><text:s/>Hallo how are you today</text:span></text:p><text:p text:style-name="P1"><text:s text:c="116"/>I hope you are well also</text:p><text:p text:style-name="P1""
How do I set the text:c and text:s element(s) from within oo::doc
Question2:
How do i set the formatting of a paragraph
to only extend from ie column 20 to column 80
thanks
Those elements are for runs of non-breaking spaces. the text:c attribute says how many spaces there are.
That doesn't strike me as a solution to what you want, which is to change the margins and position of a paragraph, yes?
Do you have a document that you want to use as a template, where the text will be inserted? Or ar you trying to create the entire page from scratch?
I think you want to use OpenOffice.org to create a Writer document that has the structure you want, then look at the XML to see what the markup is that accomplishes that. Look at paragraph-level styles or even frames if that is what is used. You might be able to create insertion points for your generated content by then adding magic-text phrases that you can scan for.
Then figure out how to get that done with the perl module.
I did the merging multiple documents into one singe document (Test.docx) with FeedData and it works fine.
When I open the merged document Test.docx with WinZip, content looks like this:
File1.docx, File2.docx, File3.docx, where all merged documents are being stored like external files into Test.docx file.
Now wondering if there are possibility to be created one single document Test.docx with whole content inside instead of multiple files to be stored as it noted above, this will helps me a lot when I'm making Search / Replace content since like this, we opening file by file procedure?
Note: If I open the Test.docx via MS Word and press "Save", MS Word do the job but I would like to produce the same result via code?
Thank you in advance.
Best
Tod
Take a look at this article, and see if this is what you're looking for:
http://blogs.msdn.com/b/brian_jones/archive/2008/12/08/the-easy-way-to-assemble-multiple-word-documents.aspx
Another way to merge multiple Open XML DOCX files into a single file is using the DocumentBuilder module that is part of Open-Xml-PowerTools, which is an open source lib on github.
https://github.com/OfficeDev/Open-Xml-PowerTools
more info about DocumentBuilder: http://openxmldeveloper.org/wiki/w/wiki/documentbuilder.aspx
Given that you want to do search and replace, check out OpenXmlRegex, also part of Open-Xml-PowerTools:
http://openxmldeveloper.org/blog/b/openxmldeveloper/archive/2014/07/22/search-and-replace-content-in-docx-pptx-using-regular-expressions.aspx
All open source, all free (both as in beer and speech).
The application I'm working on outputs documents to rtf format and PAGEREF fields are used in a table of contents page and an index page. The problem is that on opening the document the fields do not update and remain blank. They work correctly if you manually update the fields in Word. Is there a way to make these fields auto-update in the RTF spec?
You could try to create a Document_Open() macro, although you might not be able to add a macro to an rtf file. You might be able to add a macro at a template (.dot) and have the .rtf file reference the template.
Private Sub Document_Open()
End Sub