Wednesday, April 11, 2012

Convert a Docx file to HTML


//Add Reference
using System.Reflection; // Microsoft.Office.Interop.Word.dll

//Source File
 string strSource=@"D:\Documentfile.docx";
// Destination  File
 string strDestination=@"D:\htmlfile.html";

// Constant for WORD-TO-HTML exporting format
const int WORD_HTML_FORMAT = 8;

// Load COM-Metadata of Word application from registry
Type tWordApplication = Type.GetTypeFromProgID("Word.Application");

// Create new instance of Word
object objWord = Activator.CreateInstance(tWordApplication);

// List all documents
object objDocuments = tWordApplication.InvokeMember("Documents", BindingFlags.IgnoreCase | BindingFlags.GetProperty | BindingFlags.Public, null, objWord, new object[0]);

// Get COM-Metadata of Word Documents
Type tWordDocuments = objDocuments.GetType();

// Load source
object objDocument = tWordDocuments.InvokeMember("Open", BindingFlags.IgnoreCase | BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.OptionalParamBinding, null, objDocuments, new object[1] { strSource });

// Get COM-Metadata of Word Documents
Type tWordDocument = objDocument.GetType();

// Create HTML
tWordDocument.InvokeMember("SaveAs", BindingFlags.IgnoreCase | BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.OptionalParamBinding, null, objDocument, new object[2] { strDestination, WORD_HTML_FORMAT });

// Close Word
tWordApplication.InvokeMember("Quit", BindingFlags.IgnoreCase | BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.OptionalParamBinding, null, objWord, new object[0]);

Publishing image field Url Sharepoint 2010

using ImageFieldValue = Microsoft.SharePoint.Publishing.Fields.ImageFieldValue;


ImageFieldValue value = item["FieldName"] as ImageFieldValue;
                                    string imageUrl = "";
                                    if (value != null)
                                    {
                                        imageUrl = value.ImageUrl;
                                    }
                                    else
                                    {
                                        imageUrl = "";
                                    }


Tuesday, April 3, 2012

Unable to open Document Library in Explorer View

If you're unable to open document library in Explorer view follow these steps:
(your client does not support opening this list with windows explorer)
1. Add your site as a trusted site list in your Browser tools option

  • Start Internet Explorer.
  • On the Tools menu, click Internet Options, and then click the Security tab.
  • Click Trusted sites, and then click Sites.
  • In the Trusted sites dialog box, type the URL (http://servername:port) of your site in the Add this website to the zone box, and then click Add.
  • Click Close, and then click OK.
2.  Make sure the Web client service is Started.
3. If your are using server Machine means install Desktop Experience Feature
 

Microsoft Support

You can directly check your issues of Microsoft Products with Microsoft support service site

http://support.microsoft.com/search/




Remove obsolete users and groups


Maintain profile synchronization (SharePoint Server 2010)


Remove absolute user from User Profile  [ MSDN link]