Monthly Archives: August, 2006

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

Classic Definations…


Classic Definitions & Cool Meanings:  1. Cigarette: A pinch of tobacco rolled in paper with fire at one end & a fool at the other. 2. Love affairs : Something like cricket where one-day internationals are more popular than a five day test. 3. Marriage: It’s an agreement in which a man loses his bachelor …

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

Copying one DS to another…!


Hi All, This is the code to manually copy one DS to other DS…..   Dim objds As New DataSet Dim dr As DataRow Dim drTemp As DataRow Dim datatbl As New DataTable Dim dc As DataColumn objds.Tables.Add(datatbl) Dim newdc As DataColumn For Each dc In ds.Tables(0).Columns newdc = New DataColumn(dc.ColumnName.ToString) objds.Tables(0).Columns.Add(newdc) Next Dim I …

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 accept changes in dataset…!


Hi All, This code accepts the changes we made in dataset if u dont use it u can update data adapter….!     objDS.Tables(0).AcceptChanges() ‘ This code will accept all changes of dataset objAdapter.Update(objDS.Tables(0))

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

Child form code


Hi All, This is code for child form add it in parent form’s load event but do change the property (IS CHILD CONTAINER) to true…. and write this code in parent form   frm_login is name of FORM….! change it according to your requirements….     Dim mdiChild As New frm_LoginmdiChild.MdiParent = MemdiChild.Show()

Continue reading

Display values in ComboBox using Disconnected Architecture


Hi All, This is code for working with data sets in disconnected architecture…..     Public Class FrmAdd     Private Sub FrmAdd_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load        FillDesignations()    End Sub       Private Sub FillDesignations()        Dim objCommand As SqlCommand        Dim objDa As New DataAccess        Dim sqlADP As New SqlDataAdapter        Try            objDa.OpenDB()            …

Continue reading

Data Access Class


Hi All, This is code for a class for data access this class helps you to setup connections to data base…..!   Public Class DataAccess    Public StrConnection As String = "Server=.;Database=TMS;Integrated Security=True"    Public ObjCon As New SqlConnection    Sub openDB()        Try            ObjCon.ConnectionString = StrConnection            If (ObjCon.State = ConnectionState.Closed) Then                ObjCon.Open()             End If        Catch ex As …

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

A Complete code for sharepoint explorer


This is a complete code for sharepoint explorer enjoy it…..   Imports Microsoft.SharePoint Imports Microsoft.SharePoint.Administration Imports System.Diagnostics.Process Public Class FrmMain ‘Global Variables Dim spglobaladmin As New SPGlobalAdmin Dim spvs As SPVirtualServer Dim mylist As SPList Dim myweb As SPWeb Dim mysite As SPSite Dim mywebcol As SPWebCollection Dim myfoldercol As SPFolderCollection Dim myfolder As SPFolder …

Continue reading

How to paly with files inside folders…!


Hi All, Perhaps this code will be a useful one to play with folders and files….! Write this code behind the main form……….. just copy it and paste it…. it will work…   Imports Microsoft.SharePoint Imports Microsoft.SharePoint.Administration Imports System.Diagnostics.Process Public Class FrmMain ‘Global Variables Dim spglobaladmin As New SPGlobalAdmin Dim spvs As SPVirtualServer Dim mylist …

Continue reading