Click here to Skip to main content
15,892,643 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
after the reference of idataobject interface is created I need to bring the words in the clip board into an array excluding all the spaces in the original text. Please advice. Thank you.

here's my first part of the code:
C#
public void ReadMsWord()
{
    // variable to store file path
    string filePath = null;
    // open dialog box to select file
    OpenFileDialog file = new OpenFileDialog();
    // dilog box title name
    file.Title = "Word File";
    // set initial directory of computer system
    file.InitialDirectory = "c:\\";
    // set restore directory
    file.RestoreDirectory = true;

    // execute if block when dialog result box click ok button
    if (file.ShowDialog() == DialogResult.OK)
    {
        // store selected file path
        filePath = file.FileName.ToString();
    }

    try
    {
        // create word application
        Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
        // create object of missing value
        object miss = System.Reflection.Missing.Value;
        // create object of selected file path
        object path = filePath;
        // set file path mode
        object readOnly = false;
        // open document                
        Microsoft.Office.Interop.Word.Document docs = word.Documents.Open(ref path, ref miss, ref readOnly, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss);
        // select whole data from active window document
        docs.ActiveWindow.Selection.WholeStory();
        // handover the data to cllipboard
        docs.ActiveWindow.Selection.Copy();
        // clipboard create reference of idataobject interface which transfer the data
        IDataObject data = Clipboard.GetDataObject();


Here I'm trying to import data from a word document. The data is copied from a word file to the clip board.
I need to bring the words in the clip board into an array excluding all the spaces in the original text.
Posted
Updated 15-Sep-14 21:35pm
v3
Comments
George Jonsson 16-Sep-14 2:34am    
What code have you written so far? What is your data?
You need to show an example.

1 solution

I would start here How to: Retrieve Data from the Clipboard[^] for getting the data.

Basically you will get a string.

Then how to parse the data into a useful format is a different story.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900