Archive

Archive for the ‘Microsoft Office’ Category

Open a web page in outlook through Add-Ins

March 30, 2010 Leave a comment

The following code snippet shows how to open a web site (webpage)  inside Microsoft Outlook using Office Development with Visual Studio (VSTO). This code is tested using Outlook 2003.

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
Office.CommandBarComboBox control = (Office.CommandBarComboBox) this.Application.ActiveExplorer().CommandBars.FindControl(26,1740, missing, missing);
control.Text = "www.msn.com";
}

More references about VSTO and Outlook:

Read/write Excel and Access files without installing MS Office

March 25, 2009 1 comment

I faced an issue in multiple projects where a software application uses Microsoft Office libraries to read/write Excel or Access files, but the Microsoft Office can not be installed to the target (application) environment.  In such cases the missing DLLs stop application from working. 

To work around this problem there is a installset for 2007 Office System Driver: Data Connectivity Components which can install required DLLs on any computer.  You can download and deploy this package as part of your product. At this stage I am not aware of any restriction on using this installset, and if you find such a restriction please leave me a comment on this post. 

To download the package please refer to Microsoft Download Centre: 

URL: http://www.microsoft.com/downloads/details.aspx?familyid=7554F536-8C28-4598-9B72-EF94E038C891&displaylang=en

File name: AccessDatabaseEngine.exe

MSDN: To use this download

  1. If you are the user of an application, consult your application documentation for details on how to use the appropriate driver.
  2. If you are an application developer using OLEDB, set the Provider argument of the ConnectionString property to “Microsoft.ACE.OLEDB.12.0”
  3. If you are connecting to Microsoft Office Excel data, add “Excel 12.0” to the Extended Properties of the OLEDB connection string.
  4. If you are application developer using ODBC to connect to Microsoft Office Access data, set the Connection String to “Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=path to mdb/accdb file”
  5. If you are application developer using ODBC to connect to Microsoft Office Excel data, set the Connection String to “Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=path to xls/xlsx/xlsm/xlsb file”

Additional note: If in the source code one of Office components is instantiated then 2007 Office System Driver: Data Connectivity Components will not help. For example to run the following code it is required to have MS Excel installed on the system.

Dim objExcel As Object = CreateObject("Excel.Application")