A wordpad document object is inserted using insert>object and in "object dialog box" select "WordPad Document" from "create New" tab.
Now i want to extract this wordpad portion from the word document and save it as new file say XYZ.rtf.
I have already used "Microsoft.Office.Interop.word" for reading theword document.
The ClassType of OLEFormat in the InLineShape gives us "WordPad.Document.1"
we were able to extract those document which has classtype as "Word.Document.8"
Do you have any idea how to extract the wordpad document (having classtype = "WordPad.Document.1") from the word document.
Thank you,
Pasa
we were able to extract those document which has classtype as "Word.Document.8"
Do you have any idea how to extract the wordpad document (having classtype = "WordPad.Document.1"
Thank you,
Pasa
Guest UserPosted Jan 5, 2009, 12:45 PM
Word.Application wdApp = new Microsoft.Office.Interop.Word.ApplicationClass();
Word.Document doc = wdApp.Documents.Open(...);
Word.InlineShape wpadDoc = doc.InlineShapes[0]; // or wherever your rtf doc is
wpadDoc.Select();
wdApp.Selection.Copy();
this.rtbrichTextBox1.Paste();
this.rtbrichTextBox1.SaveFile("YOUR SAVE FILEPATH HERE");
Clipboard.Clear(); // to prevent Word from alerting you about clipboard data when it quits
It copies the embedded object to the clipboard and then pastes it into the form's richtextbox. Then it uses the savefile method of the richtextbox to save a copy of the rtf.
There may be a better solution using reflection. For example:
Type wordpadDocType = Type.GetTypeFromProgID("WordPad.Document.1");
This will get the type information for WordPad document objects.
Ramesh ShresthaPosted Jan 6, 2009, 6:05 AM
Its because of your help the target is achieved.
Guest UserPosted Jan 5, 2009, 3:18 PM
Using Reflection, you can create a Wordpad document object:
Type wordpadDocType = Type.GetTypeFromProgID("WordPad.Document.1");
object wordpadDoc = System.Activator.CreateInstance(wordpadDocType);
The problem is that you would need to use the InvokeMember method on the document object to get it to perform tasks (setting properties, calling methods, etc.) but I can't find any documentation on Wordpad to see if it's even possible to do that.
Sorry I can't be more help here.
Ramesh ShresthaPosted Jan 5, 2009, 2:04 PM
At least give me the hope that it can be done.
Can it be done without using richtextbox or any other user interface for saving the selected wordpad?
Thank you