Category Archives: Visual Studio Tools for Office

Reading emails & email headers from Outlook mail using C# – Part I


First, some news about myself, I left PiSigma Group, Islamabad and now working with DigiDent solutions Pvt. Ltd as Sr. Consultant. It’s a very good place to work in with lots of growth opportunities. At-least, hopefully, I will get paid on time here  Now something about my latest work in this company. It was my …

Continue reading

How to get values of a excel row in actionpane using VSTO


Hi all this code will help you to get the data of the selected row of excel sheet in the actionpane with textboxes same in number as the columns of the row…..         Private Sub BtnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEdit.Click Try Globals.ThisWorkbook.ActionsPane.Controls.Add(apedit) Dim dsSrc As DataTable = …

Continue reading

How to select a row of excel using VSTO in VS 2005


Private Sub List1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Try selectedrow = List1.SelectedIndex + 1 Globals.Sheet2.List1.Range.EntireRow().Select() List1.Range.EntireRow(selectedrow).Select() Catch ex As Exception MsgBox(ex.ToString) End Try End Sub

Continue reading

Display MessageBox on changing value of cell


Hi All this code will display a message box upon changing the cell value of any cell with the cell ref and value     Messagebox.show(string.format("You changed cell (0) to {1}", Target.Address, Target.Value))    

Continue reading

Creating update stored procedure….!


Hi All this is code for the stored procedure for updation…. ENJOY   First you have to declare the variable which recieve values with @ sign…… and for a variable which does not recieve value but get value from within the stored procedure, the keyword is DECLARE   so here’s the code this code needs …

Continue reading

Creating a Stored Procedure for Insertion….!


Hi All…. This code shows us how to write a stored procedure…. First of all we have to define parameters which must be of same data type as of SQL DataBase….     ALTER PROCEDURE SP_CreateProjectTeam @ProjectCode varchar(50), @ProjectName varchar(50), @TeamMembers varchar(50) AS /* SET NOCOUNT ON */ INSERT INTO TblProjects (ProjectCode, ProjectName) VALUES (@ProjectCode,@ProjectName) …

Continue reading

How to clear list values but keep the list…!


Hi All… This code will help you to keep the list and clear its values…     Globals.Sheet1.List1.DataSource = Nothing

Continue reading

Hot to get a value of cell using VSTO


Hi All with this code u can get the cell values of a row of an excel sheet….. try it   Dim apedit As New APEditValues Globals.ThisWorkbook.ActionsPane.Controls.Add(apedit) Dim dsSrc As DataTable = Nothing Src = Globals.Sheet1.List1.DataSource Dim intValue As Integer = Globals.Sheet1.List1.SelectedIndex – 1 apedit.EditProjectCodeTextBox.Text = dsSrc.Rows(intValue)(0).ToString apedit.EditProjectNameTextBox.Text = dsSrc.Rows(intValue)(1).ToString apedit.EditTeamMembersTextBox.Text = dsSrc.Rows(intValue)(2).ToString     …

Continue reading

How to Install VSTO….. Sequence of installations


Hi All….   When you are installing Visual Studio Tools for Office you should keep in mind the following sequence….   1. Install Windows Latest Service Pack (SP2 for Win XP and SP1 for Windows Server 2003) 2. Install SQL Server 2000 3. Install SQL Server SP3 4. WINFX Feb CTP (Go to http://www.Microsoft.com and write …

Continue reading

How to remove empty data rows from data set


Hi All, This code will remove empty rows from data set (Remember i have used VSTO to add excel sheet records)   Dim dr As DataRow ‘ This code removes empty rows from DataSet For Each dr In objDS.Tables(0).Rows If (dr.IsNull(0)) And (dr.IsNull(1)) Then dr.Delete() End If Next

Continue reading

How to fill Records from excel sheet into Datagrid..!


strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:data.xls;Extended Properties=""Excel 8.0;HDR=NO;""" objConn = New OleDb.OleDbConnection(strConn) objConn.Open() ‘sql = "SELECT Project Name FROM [Data$]" Sql = "SELECT * FROM [Data$]" Dim objCommand As New OleDb.OleDbCommand(sql, objConn) Dim objAdapter As New OleDb.OleDbDataAdapter(objCommand) Dim objDS As New DataSet objAdapter.Fill(objDS) ‘CbProjectName.DataSource = objDS.Tables(0).DefaultView ‘CbProjectName.DisplayMember = objDS.Tables(0).Columns(1).ColumnName ‘CbProjectName.ValueMember = objDS.Tables(0).Columns(0).ColumnName Dim dr As DataRow ‘ …

Continue reading

Play with cells of excel sheet using VSTO


Hi this is the code to play with cells of excel sheet using VSTO   check it out   Dim selectedrow As Integer selectedrow = List1.SelectedIndex + 1 List1.Range.EntireRow(selectedrow).Select() actionpane.TbID.Text = List1.Range.ListObject.ListRows.Item(selectedrow).Range.ListObject.ListColumns(1).Name.ToString   Ahmed Muneeb Cell No. +92-321-6218648 Junior Software Engineer      

Continue reading

Code to get cell title in action pane using VSTO


Hi this is the code which will get the excel cell’s titles for you in action pane’s textbox so check it out   actionpane.TbID.Text = List1.Range.ListObject.ListRows.Item(selectedrow).Range.ListObject.ListColumns(1).Name.ToString

Continue reading