Conectar excel a vb2010 para botón de búsqueda ayuda

hola a todos... Estoy haciendo un formulario de registro de clientes en visual studio 2010

el cual tiene un form de registro con varios txtbox y botones

lo que hace es llenar campos (txtbox) y mediante el botón guardar envía los datos a un

documento de excel...eso ya lo logre... Pero ahora necesito programar un botón de buscar

ok.

en mi formulario principal existe un botón guardar que me envía

a otro formulario que contiene un txtbox un botón de guardar, otro de ver , otro de modificar y un datagrid

lo que no se hacer es.

1. Que al escribir el dato que quiero buscar dentro del libro de excel y dar clic al botón buscar me arroje el resultado en el datagrid... Para que si por ejemplo busco por nombre

"juan" y existan varios con el mismo me los ponga todos y pueda seleccionar el que deseo y después , en caso de querer modificarlo me arroje todos los datos al form1 al dar clic en el botón modificar y lo ponga en su campo correspondiente para así modificarlo y después guardarlo y me elimine el anterior y lo sustituya con el nuevo dato.

2. Esto mismo pero ahora en el botón ver pero que esta vez me lo arroje a un nuevo formulario y que esos datos que quiero ver me los arroje a labels que no puedan alterarse para así poder imprimirlos desde ahí.

nota soy nuevo en esto de la programación, ojala puedan ayudarme...

no estoy utilizando el oledb

creo que no estoy utilizando sql

y no hice conexión con base de datos

SOLO FUI A PROJECT Y ADD NEW REFERENCE Y SELECCIONE MI DOCUMENTO

************FORM 1*************

Public Class Form1
'permite que la ventana este centrada en la pantalla
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Top = (Screen.PrimaryScreen.WorkingArea.Height - Me.Height) / 2
Me.Left = (Screen.PrimaryScreen.WorkingArea.Width - Me.Width) / 2
End Sub
'botón guardar
Private Sub cmb_guardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb_guardar.Click
'valida que los campos estén llenados correctamente
If txt_ap_pat.Text = "" Or txt_ap_mat.Text = "" Or txt_nombre.Text = "" Or txt_calle.Text = "" Or txt_ext.Text = "" Or txt_col.Text = "" Or txt_cp.Text = "" Or txt_mun.Text = "" Or txt_estado.Text = "" Or txt_pais.Text = "" Or txt_fb.Text = "" Or txt_twit.Text = "" Or txt_inst.Text = "" Or txt_mail.Text = "" Or txt_tel.Text = "" Or txt_cel.Text = "" Or txt_em_nombre.Text = "" Or txt_em_tel.Text = "" Or txt_parent.Text = "" Then
MsgBox("Debes rellenar todos los campos para continuar. Solo el campo de Numero Interior es (Opcional). ", vbCritical, "Error al Guardar Registro")
Else 'en caso de estar llenos abrira el archivo de excel
abrir_archivo_clientes()
agregar_datos()
guardar_registro()
End If
End Sub
'botón cancelar sirve para cerrar el formulario sin guardar datos
Private Sub cmb_cancelar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb_cancelar.Click
'MsgBox("Seguro que desea cerrar la aplicacion", MsgBoxStyle.YesNo, "Desea Salir")
'Me.Close()
If MessageBox.Show("Seguro que quiere salir de la aplicación", "Cierre de Aplicación", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
End
Else
End If
End Sub
'limpiara todos los campos SIN guardar solo ahorrara tiempo de borrar, para ingresar un nuevo cliente
Private Sub cmb_limpiar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb_limpiar.Click
'surgira una ventana advirtiendo que no se guardaran los datos
If MessageBox.Show("Seguro que desea limpiar todos los campos de registro, los datos ingresados no se guardaran.", "Limpiar Campos de Registro", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
txt_ap_pat.Text = Nothing
txt_ap_mat.Text = Nothing
txt_nombre.Text = Nothing
txt_calle.Text = Nothing
txt_int.Text = Nothing
txt_ext.Text = Nothing
txt_col.Text = Nothing
txt_cp.Text = Nothing
txt_mun.Text = Nothing
txt_estado.Text = Nothing
txt_pais.Text = Nothing
txt_fb.Text = Nothing
txt_twit.Text = Nothing
txt_inst.Text = Nothing
txt_mail.Text = Nothing
txt_tel.Text = Nothing
txt_cel.Text = Nothing
txt_em_nombre.Text = Nothing
txt_em_tel.Text = Nothing
txt_parent.Text = Nothing
Else
End If
End Sub
Private Sub cmb_buscar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb_buscar.Click
Buscar.Show()
End Sub
End Class

*************ESTE SE LLAMA MODULO VARIABLES*********

Imports excel = Microsoft.Office.Interop.Excel
'son las ordenes generales que se le dan al programa
Module Variables
Public obj_excel As excel.Application
Public obj_libros As excel.Workbooks
Public obj_hoja_clientes As excel.Worksheet
'Esta variable hace referencia a la ruta en la cual se encuentra el archivo tipo .xls (excel) sobre el cual se esta trabajando
Public obj_archivo_cliente = ("C:\Users\Lucia\Desktop\micarpeta \misdatos\mihoja")
End Module

*****ESTE SE LLAMA MODULO SENTENCIAS******

Module Sentencias
'ejecuta el archivo en el que se guardaran los datos
Sub abrir_archivo_clientes()
Try
'intenta abrir el archivo
obj_excel = CreateObject("Excel.Application")
With obj_excel
.Workbooks.Open(obj_archivo_cliente)
obj_hoja_clientes = .ActiveWorkbook.Sheets("Rebelion DB")
obj_hoja_clientes.Activate()
.Visible = False 'permite que se visible o no la hoja de excel
End With
Catch ex As Exception
'en caso de no poder abrir el archivo personalizo pantalla de error
MsgBox("No se pudo abrir el archivo espcificado puede que haya sido eliminado", MsgBoxStyle.Critical, "Error al Abrir Archivo")
End Try
End Sub
'busca los campos en el que se quiere que se ingrese la informacion
Sub agregar_datos()
With obj_excel
obj_hoja_clientes.Range("a65536").End(Microsoft.Office.Interop.Excel.XlDirection.xlUp).Offset(1, 0).Activate()
.ActiveCell.Value = Form1.txt_ap_pat.Text.ToUpper
.ActiveCell.Offset(0, 1).Value = Form1.txt_ap_mat.Text.ToUpper
.ActiveCell.Offset(0, 2).Value = Form1.txt_nombre.Text.ToUpper
.ActiveCell.Offset(0, 3).Value = Form1.txt_calle.Text.ToUpper
.ActiveCell.Offset(0, 4).Value = Form1.txt_int.Text.ToUpper
.ActiveCell.Offset(0, 5).Value = Form1.txt_ext.Text.ToUpper
.ActiveCell.Offset(0, 6).Value = Form1.txt_col.Text.ToUpper
.ActiveCell.Offset(0, 7).Value = Form1.txt_cp.Text.ToUpper
.ActiveCell.Offset(0, 8).Value = Form1.txt_mun.Text.ToUpper
.ActiveCell.Offset(0, 9).Value = Form1.txt_estado.Text.ToUpper
.ActiveCell.Offset(0, 10).Value = Form1.txt_pais.Text.ToUpper
.ActiveCell.Offset(0, 11).Value = Form1.txt_fb.Text.ToUpper
.ActiveCell.Offset(0, 12).Value = Form1.txt_twit.Text.ToUpper
.ActiveCell.Offset(0, 13).Value = Form1.txt_inst.Text.ToUpper
.ActiveCell.Offset(0, 14).Value = Form1.txt_mail.Text.ToUpper
.ActiveCell.Offset(0, 15).Value = Form1.txt_tel.Text.ToUpper
.ActiveCell.Offset(0, 16).Value =...

Añade tu respuesta

Haz clic para o