Dec 11, 2011

Reading Summary Properties of Word Document

Part II
Read the Introduction about this article Part I
In this post, we can see what is the code for the reading the summary properties of the word document.
public static void GetDocumentSummaryProperties(string filename)
{
            DSOFile.OleDocumentPropertiesClass doc = new DSOFile.
            OleDocumentPropertiesClass();
            doc.Open(filename, false,

            DSOFile.dsoFileOpenOptions.dsoOptionOpenReadOnlyIfNoWriteAccess );

            //getting the properties of the document
            DSOFile.SummaryProperties summaryProp = doc.SummaryProperties;

            //reading and writng the summary properties to a file
            string author = summaryProp.Author;
            string comapanyName = summaryProp.Company;
            string managerName = summaryProp.Manager;
            StreamWriter sw = new StreamWriter(@"D:\FileRead.txt");
            sw.WriteLine(author);
            sw.WriteLine(comapanyName);
            sw.WriteLine(managerName);
            sw.Close();
}
That’s It. Enjoy Happy Coding!
Also, read how to Read the Custom Properties of Word Document Part III

Reading Document Properties

Part I
We are going to discuss about a interesting topic which can be used in SharePoint and also in .Net.
It is possible to reading the summary properties and custom properties of the word document and it is also one of the requirements now a days.
This can be done through using DSO dll which can be downloaded from the below link
(Important Note: This is a 32 bit dll )

What is DSO dll ?
The Dsofile.dll sample file is an in-process ActiveX component for programmers that use Microsoft Visual Basic .NET or the Microsoft .NET Framework. You can use this in your custom applications to read and to edit the OLE document properties that are associated with Microsoft Office files, such as the following: 
• Microsoft Excel workbooks
• Microsoft PowerPoint presentations
• Microsoft Word documents
• Microsoft Project projects
• Microsoft Visio drawings
• Other files that are saved in the OLE Structured Storage format
The Dsofile.dll sample file is written in Microsoft Visual C++. The Dsofile.dll sample file demonstrates how to use the OLE32 IPropertyStorage interface to access the extended properties of OLE structured storage files.
Features of this DLL
1. This dll is 32 bit and can read only Microsoft word 2003 (ie., .doc) formats only.
2. It has a OLE property reader class which can read the properties of the word document.
3. Using this dll, we can read both the Summary properties and also the Custom properties we create for the documents.
4. Also with this dll, we can set the custom properties programmatically.

Also, Read how to extract the summary properties of the word document in this article Part II.

Twitter WebPart for SharePoint

I have already posted a link which will guide you in creating the twitter and Face book web parts for SharePoint in this article. Twitter and FaceBook for SharePoint. Have a look at this.
Yet another easiest way for twitter is as follows:
Steps:
1. Open the site page where you want to add the twitter widgets.
2. Add a Content Editor Web part.
3. Now open this URL in your browser
4. You will find 4 widgets (in the Widgets for my site option) which is provided by default in the Twitter Official Site
·                      Profile Widget
·                     Search Widget
·                     Faves Widget
·                     List Widget
5. All the information about the widgets will be given the site.
6. Now for example I will add the SEARCH WIDGET to our site. I click on Search Widget which will navigate to this link
7. You have 4 options such as Settings, Preferences, Appearance and Dimensions.
8. Here you can customize everything and my sample is shown code grabbed from the site is shown below.
<script src="http://widgets.twimg.com/j/2/widget.js">
</script>
<script>
new TWTR.Widget({
  version: 2,
  type: 'search',
  search: 'SharePoint',
  interval: 30000,
  title: 'What people are saying about',
  subject: 'SharePoint',
  width: 250,
  height: 300,
  theme: {
    shell: {
      background: '#8ec1da',
      color: '#ffffff'
    },
    tweets: {
      background: '#ffffff',
      color: '#444444',
      links: '#1985b5'
    }
  },
  features: {
    scrollbar: false,
    loop: true,
    live: true,
    hashtags: true,
    timestamp: true,
    avatars: true,
    toptweets: true,
    behavior: 'default'
  }
}).render().start();
</script>

9. That’s it!! Add this code in the Source Editor of the Content Editor Web Part.
10. This will display all the tweets with respect to the Query you gave in the Search. The webpart will look like this.


11. Save it!! Enjoy the Twitter integration in your SharePoint Site.

RSS Feeds WebPart

In this post we will see how to create RSS feeds web part for SharePoint. it is very easy and we will learn it in the following steps.
1. Add a XML web part to a share point page where you want to add the RSS Feeds web part.
2. Edit the properties of the web part.
3. In the XSL editor place the code (given below).
4. In the XML link give the proper RSS feeds URL.
5. Click Save.
6. This will display the RSS feeds from the URL linked in the web part.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xsl">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<div>
<xsl:apply-templates select="rss/channel"/>
</div>
</xsl:template>
<xsl:template match="rss/channel">
<xsl:variable name="link" select="link"/>
<xsl:variable name="description" select="description"/>
<ul><xsl:apply-templates select="item"/></ul>
</xsl:template>
<xsl:template match="item">
<xsl:variable name="item_link" select="link"/>
<xsl:variable name="item_title" select="description"/>
<xsl:if test="position() &lt; 6">
<li>
 <a href="{$item_link}" title="{$item_title}"><xsl:value-of select="title"/></a>
 </li>
</xsl:if>
</xsl:template>
</xsl:stylesheet>

Copying the File from and to Document Library in SharePoint

Let’s see how to copy the file from and to the document library using object model.
SPSite site = new site("http://siteurl");
using (site)
{
    SPWeb web = site.OpenWeb();
    using (web)
    {
        SPList lib1 = (SPDocumentLibrary)web.Lists["lib1"];
        SPList lib2 = (SPDocumentLibrary)web.Lists["lib2"];
        SPListItem item1 = lib1.Items[0];
        byte[] fileBytes = item1.File.OpenBinary();
        string destUrl = lib2.RootFolder.Url   "/"   item1.File.Name;
        SPFile destFile = lib2.RootFolder.Files.Add(destUrl, fileBytes, true);
    }
}

That’s it! Happy coding!

Displaying Multiple Document Libraries in a Single WebPart

A frequent requirement in the Share Point Projects is Displaying Multiple Libraries together in a single web part. It can be achieved by various methods but I am going to create it through Share Point Designer 2007.
In this article we will come to know how it can be done step by step.

1. The Important thing here to be noted is, whatever may be the number of Document Library going to be merged here, and it should contain the same number of columns and name.
2. If not, this web part won’t work.
3. Create two document libraries (Example : Test1,Test 2)
4. I have created 4 columns such as Type, Title, Name, and Created by in both document libraries.
5. Now, we are going to use the designer 2007 here to proceed.
6. Open the site in designer –> create an .aspx page.
7. In the right side of the designer -> go to Data Source Library -> Linked Sources
8. In the Linked Sources click -> create a New Linked Source.
9. We have Three Tabs here ,
General
a. In General -> Give the Name of the web part
b. In Description-> Give  the Description of your web part
c. In Key Words -> Give the Keywords if u like
Source
a. Click Configure Linked Source -> Pop up window will Show all the  Available Data Sources  as shown below
b. Under the SharePoint Libraries -> add the two document libraries created (Test1,Test 2)
c. Click Next Button


d. Leave the default option (Merger the contents of the data sources….)
e. Click Finish and it show it as shown below.
f. Click ok.
10. Now open the page where you want to add the web part in the designer. Then click “Click to insert a web part” option in the page.
11. In the Data Source Library under Linked Sources you will see the created (here I gave it as Multiple Document Libraries in Single List) the linked source as shown below.

12. Click on the Drop Down in the created Linked Source and click Show Data which will show the “Data Source Details” as shown below.
13. You will see all the columns present in the Document Libraries.
14. Press CTRL and select the columns which you want to display in the Web Part.
15. Then Click on the Insert Selected Fields as…  -> Select Multiple Item View
16. I have selected Name for Use in Forms, Created by and Path from the columns and inserted it in the site which is as follows.
17. We have to format this view so that it looks good to view.
a. First Column is formatted so that select the Format as with Label
b. Then second column  created by in the same way select Format as with Label
c. Finally third column select Format as with hyperlink and give the following the pop-up window.
     Address: /{@FileDirRef}
     Label: {@FileDirRef}
18. We have completed creating the web part. Finally it will look as shown below.


So we are now able to list and view the documents from two document libraries as shown below !!!

Dec 9, 2011

Recommendations for maintaining Infopath performance

I'm creating an InfoPath form that is a bit large and starting to lag so I decided to look up better practices for developing InfoPath forms to maintain performance. Here is what I found online:
- Keep views from being too large or complex. Split large views into several smaller ones with buttons to switch between them.
- Avoid lots of tables (data or layout) in any single view.
- Use Master/Detail to reduce the number of controls in one page, whenever possible.
- Try to use filter to filter the table rows (instead of conditional
formatting).
- Avoid large repeating data structures that can grow to many pages.
-Avoid complex nesting of optional and repeatable sections. These are quite complicated to layout and also can quickly cause a single view to become very large.
- Avoid using Percentage width for your controls if your view contains lots of nested controls. We have seen over 50% improvements by using Fixed Width. You can apply specify a fixed width in the control's properties dialog.
- Be aware of exactly what your business logic does. For example, onAfterChange can fire multiple times for a single edit.
- Rather than querying for all the data then having InfoPath just show a small amount, refine your query and only bring the data you plan on displaying into InfoPath.
- Only get the data you need to load the form. Don't pre-populate data sources that aren't necessary on load.
- Merge static xml data sources into one if you have multiple xml data connections.
- Use Expression Box to display calculated value if you don't need to store the value. If you have business logic to trigger all the calculation, only trigger necessary calculation. Triggering large amount of calculations is costly.
- When using digital signatures, only digitally sign the information you need to. Signing takes a screenshot of the data signed and encodes it in the form. The larger the screenshot, the larger the xml will become with the encoded image.
- Avoid attaching large files to the form. These files are encoded in the xml and can cause issues if they become too large. Provide links over embedding large files if possible.
- Avoid embedding images in a form. For the same reasons as above.

SharePoint Designer opens in contributor mode

We may face some situation, while editing the site using Sharepoint Designer, it will get open in Contributor mode and we will not be able to edit the site, eventhough we have the Site Collection Administrator(SCA) permission.
 By default, Contribute permissions are assigned to the Site Collection Members  group. Even though, we are part of SCA group, if we are member of Site Collection members the Designer will open in Contributor mode.
To overcome this just disable the contributor settings in SharePoint designer by using the below steps:
1. Open the site in SharePoint Designer.
2. Select the Site Tab -> Contributor Settings.
3. Click on Disable Contributor settings button.
Now we will be able to edit the site.

How to convert Infopath form to word document

Sometimes you may need to convert an InfoPath form into a Word document so you can send it to users that either don’t have InfoPath or can’t access your  SharePoint form library. Luckily there is an easy process to do so.
Steps to convert InfoPath form to Word:
1) Open your .xsn InfoPath project file
2) Go to File -> Export To -> Web
3) Enter a name for the file and make sure “Single File Web Page (*.mht;*.mhtml)” for Save as type is selected. Click Export
4) Locate your new .mht file and open it with Word.
5) You should see your InfoPath form in Word. You may have to adjust any checkboxes or radio buttons that may be on the form. Make sure to save the file as a .doc or .docx file type when you’re done

Integrating Twitter and FaceBook in SharePoint

I would like to share the link which is very simple and clear way of integrating the twitter and facebook in SharePoint.

Twitter Integration


Face Book Integration