UseOffice .Net - Robust .Net component to convert between Text, RTF, DOC, DOCX, HTML, XHTML, XLS, XLSX, CSV, PPT and PDF documents.
version 2.02 (June 1st, 2009)
Help Content | About UseOffice .Net | Methods and properties | Samples of using in C#, VB.Net, ASP.Net | License | Pricing | Support and Contacts

Using UseOffice .Net version in VB.Net and C#, ASP.Net

 C#
 VB.Net
 ASP.Net

C# sample


1. Place these files into your bin directory:

  • UseOffice.dll
  • office.dll
  • Microsoft.Office.Interop.Word.dll
  • Microsoft.Office.Interop.PowerPoint.dll
  • Microsoft.Office.Interop.Excel.dll

2. In VisualStudio (2003, 2005 or 2008) manually add a reference to the file "UseOffice.dll" via "Add reference" for the current project.

 

3. Example C# - convert one file:
 SautinSoft.UseOffice u = new SautinSoft.UseOffice();
 u.ConvertFile(@"d:\text.doc", @"d:\text.html", SautinSoft.UseOffice.eDirection.DOC_to_HTML);

        

3.1. Example C# - convert collection of files:

	SautinSoft.UseOffice u = new SautinSoft.UseOffice();
	string docFolder = @"d:\doc\";
	string htmlFolder = @"d:\html\";
	string[] files = Directory.GetFiles(docFolder, "*.doc");
			 
	//load MS Office in memory
	int office = u.InitOffice();
	
	//0 - loading OK
	//1 - can't load MS Excel (Word and PowePoint OK)
	//10 - can't load MS Word (Excel and PowerPoint OK)
	//11 - can't load MS Word and Excel (PowerPoint OK)
	//100 - can't load MS PowerPoint (Excel and Word OK)
	//101 - can't load MS Excel and PowerPoint (Word OK)
	//110 - can't load PowerPoint and Word (Excel OK)
	//111 - can't load MS Office
    
	if (office==0 || office==100 || office==101)
	{ 
	}
	else
	{
		//MS Office isn't installed
		return;
	}
    
	for (int i=0; i<files.Length; i++)
	{
		string htmlName = Path.Combine(htmlFolder,Path.GetFileNameWithoutExtension(files[i])+".htm");
		u.ConvertFile(files[i], @"d:\text.html", SautinSoft.UseOffice.eDirection.DOC_to_HTML);
	}
	u.CloseOffice();  

VB.Net sample


1. Place these files into your bin directory:

  • UseOffice.dll
  • office.dll
  • Microsoft.Office.Interop.Word.dll
  • Microsoft.Office.Interop.PowerPoint.dll
  • Microsoft.Office.Interop.Excel.dll

2. In VisualStudio (2003, 2005 or 2008) manually add a reference to the file "UseOffice.dll" via "Add reference" for the current project.

 

 
3. Example VB - convert one file:
  Dim u As New SautinSoft.UseOffice()
u.ConvertFile("d:\text.doc", "d:\text.html", SautinSoft.UseOffice.eDirection.DOC_to_HTML)

3.1. Example VB - convert collection of files:

	Dim u As New SautinSoft.UseOffice()
	Dim docFolder As String = "d:\doc\"
	Dim htmlFolder As String = "d:\html\"
	Dim files() As String = Directory.GetFiles(docFolder, "*.doc")
	
	'load MS Office in memory
	Dim office As Integer = u.InitOffice()		
	
	'0 - loading OK
	'1 - can't load MS Excel (Word and PowePoint OK)
	'10 - can't load MS Word (Excel and PowerPoint OK)
	'11 - can't load MS Word and Excel (PowerPoint OK)
	'100 - can't load MS PowerPoint (Excel and Word OK)
	'101 - can't load MS Excel and PowerPoint (Word OK)
	'110 - can't load PowerPoint and Word (Excel OK)
	'111 - can't load MS Office		
	
	If office=0 OrElse office=100 OrElse office=101 Then
	Else
	'MS Office isn't installed
	Return
	End If		

	For i As Integer = 0 To files.Length - 1
		Dim htmlName As String = Path.Combine(htmlFolder,Path.GetFileNameWithoutExtension(files(i)) & ".htm")
		u.ConvertFile(files(i), "d:\text.html", SautinSoft.UseOffice.eDirection.DOC_to_HTML)
	Next i
	u.CloseOffice() 
© Copyright SautinSoft™ 2002 - 2009