Programmatically Access Word 2007 Document From DIP - InfoPath Dev
in

InfoPath Dev

Programmatically Access Word 2007 Document From DIP

Last post 01-04-2010 09:49 AM by eddyblanco. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 12-27-2009 05:36 PM

    Programmatically Access Word 2007 Document From DIP

    I have a custom document information panel in InfoPath 2007 that is based on a SharePoint content type. Is it possible to access the Word document from managed code in the DIP?
  • 01-03-2010 04:26 AM In reply to

    • rikigo
    • Not Ranked
    • Joined on 01-03-2010
    • Posts 2

    Re: Programmatically Access Word 2007 Document From DIP

    I also have this question..

    can anyone  help me please?

     

    riki.

     

  • 01-03-2010 04:41 AM In reply to

    Re: Programmatically Access Word 2007 Document From DIP

    I'm not sure of the answer, but what I would do is. Download http://spm.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=22762

    and see if the content type has the values you are looking for, if it does I could send you some code.

    Hope that helps

  • 01-03-2010 05:54 AM In reply to

    • rikigo
    • Not Ranked
    • Joined on 01-03-2010
    • Posts 2

    Re: Programmatically Access Word 2007 Document From DIP

    Thank you for your help and the quick answer !

    I download the project like you suggest .

    since its a big project can you please direct me to the class or object I need to add to my code in order to access Word 2007 Document from DIP .

    thanks riki.

     

     

  • 01-03-2010 06:31 AM In reply to

    Re: Programmatically Access Word 2007 Document From DIP

    Hello Riki,

    Actually this is to deternmine if you see the values you are looking for on the content type.

    1) Open the Infopath form as usual with the Word 2007 content. 2) On the server running MOSS open "Sharepoint Manager 2007" 3) GO to the site collection hosting the Infopath form, and take a look at the content type value's

    Let me know if you see the content you are looking for.

  • 01-04-2010 07:55 AM In reply to

    Re: Programmatically Access Word 2007 Document From DIP

    In my case, yes the values that I care about are in the content type.
  • 01-04-2010 08:14 AM In reply to

    Re: Programmatically Access Word 2007 Document From DIP

    Which list or forms library list is the content type asscoaited to?

  • 01-04-2010 09:49 AM In reply to

    Re: Programmatically Access Word 2007 Document From DIP

    If you have the values of the content type as mention. Below is just an example to guide you. there are other way to do the same.

    Use the web service for the list

    //get the name of the file

               XPathNavigator xnDoc = this.MainDataSource.CreateNavigator();

                //Create a Navigator object for the field that you want to set.
                XPathNavigator TitleDescription = xnDoc.SelectSingleNode(”/my:TitleDescription”, this.NamespaceManager);

     //so now I assume you will have the name of the file or what you are queryn for.

               SPSListWeb.Lists listService = new SPSListWeb.Lists();

                /*Authenticate the current user by passing their default
                credentials to the Web service from the system credential cache.*/
                listService.Credentials = System.Net.CredentialCache.DefaultCredentials;
                listService.PreAuthenticate = true;

                /*Set the Url property of the service for the path to a subsite.*/
                listService.Url = “http://xxxxxx/_vti_bin/lists.asmx“;
                listService.PreAuthenticate = true;

                /*Get Name attribute values (GUIDs) for list and view. */
                System.Xml.XmlNode ndListView = listService.GetListAndView(”thelistname”, “”);
                string strListID = ndListView.ChildNodes[0].Attributes["Name"].Value;
                string strViewID = ndListView.ChildNodes[1].Attributes["Name"].Value;

                /*Create an XmlDocument object and construct a Batch element and its attributes. Note that an empty ViewName parameter causes the method to use the default view. */
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                System.Xml.XmlElement batchElement = doc.CreateElement(”Batch”);
                batchElement.SetAttribute(”OnError”, “Continue”);
                batchElement.SetAttribute(”ListVersion”, “1″);
                batchElement.SetAttribute(”ViewName”, strViewID);

     

              
                XmlDocument documentQuery = new XmlDocument();
                XmlElement query = documentQuery.CreateElement(”Query”);
                System.Xml.XmlElement viewFields = documentQuery.CreateElement(”ViewFields”);
                // The CAML query to return what I’m looking for.
                query.InnerXml = ” <Where>” +
                       “<Eq>” +
                          “<FieldRef Name=\”Title\” />” +
                          “<Value Type=\”Text\”>” + TitleDescription + “</Value>” +
                       “</Eq>” +
                 “</Where>”;

    //now just get the name of the field you need. this is just an example to guide you

Page 1 of 1 (8 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.