Visual Basic - Búsqueda inteligente en word

Life is soft - evento anual de software empresarial
 
Vista:

Búsqueda inteligente en word

Publicado por Jimmy (1 intervención) el 25/05/2018 01:55:37
Hola,hice un sencillo motor de búsqueda con userform en excel, donde funciona bien, pero mi idea es también poder utilizarlo en word. El motor consta de: un textbox (ingreso), donde se introducen la palabra a buscar
listbox (listbox1), que se llena con la/s palabra/s que coinciden con la busqueda
textbox (textbox1), donde se inserta la definición de la palabra seleccionada en el listbox1
botones de limpiar y cerrar

Hasta el momento he logrado se abra el motor y que busque las palabras (llenado el lisbox1), pero me salta error al momento de insertarse la definición en textbox1. Si alguien puede ayudarme con esto, agradecería.

Pego abajo el código y marcado donde tengo el error

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
Private Sub ListBox1_Click()
AutoSize = True
 
Cuenta = Me.ListBox1.ListCount
 
For i = 0 To Cuenta - 1
    If Me.ListBox1.Selected(i) = True Then
         Me.Height = 275.75
 
         TextBox1.Visible = True
 
        valor = Me.ListBox1.List(i) 'ORIGINAL de excel
        'sheets("Hoja2").Range("D6").Value = Valor     'ORIGINAL de excel
 
     xlWB.Worksheets("Hoja2").Range("D6").Value = valor
 
         xlWB.Sheets("Hoja2").Select
 
            TextBox1.Text = ActiveCell
 
    End If
Next i
'
End Sub
'
 
Private Sub CommandButton3_Click()
Unload Me
Me.Height = 53
ingreso.Value = Clear
ListBox1.Value = Clear
TextBox1.Value = Clear
 
 
 
 
End Sub
 
Private Sub ingreso_Change()
Me.Height = 128.25
 
On Error GoTo Errores
'
Set xlApp = CreateObject("Excel.Application")
  'Open the spreadsheet to get data
  Set xlWB = xlApp.Workbooks.Open("F:\glosaRIO.xlsm")
  Set xlWS = xlWB.Sheets("Hoja2")
If Me.ingreso.Value = "" Or Me.ingreso.Value = " " Then
 
    Me.ListBox1.Clear
 
        '
    Else
    Me.ListBox1.Clear
 
        j = 1
 
    Set HojaBase = xlWB.Sheets("Hoja2")
 
         Filas = HojaBase.Range("A1").CurrentRegion.Rows.Count
 
    For i = 2 To Filas
 
         If LCase(HojaBase.Cells(i, j).Value) Like "*" & LCase(Me.ingreso.Value) & "*" Then
            Me.ListBox1.AddItem HojaBase.Cells(i, j)
 
        Else
 
              End If
    Next i
End If
'
Exit Sub
Errores:
MsgBox "No se encuentra.", vbExclamation, "EXCELeINFO"
 
  Set xlWS = Nothing
  Set xlWB = Nothing
  'xlApp.Quit
  Set xlApp = Nothing
'lbl_Exit:
 ' Exit Sub
'End Sub
 
End Sub
 
 
 
 
Private Sub TextBox1_Change()
 
 
End Sub
 
Private Sub UserForm1_Click()
 
End Sub
 
 
 
 
Private Sub Userform_Initialize()
Me.Height = 48.75
'UserForm1.Show vbModeless
'Late binding.  No reference to Excel Object required.
Dim xlApp As Object
Dim xlWB As Object
Dim xlWS As Object
Dim cRows As Long
'Dim i As Long
  Set xlApp = CreateObject("Excel.Application")
  'Open the spreadsheet to get data
  Set xlWB = xlApp.Workbooks.Open("F:\glosaRIO.xlsm")
  Set xlWS = xlWB.Worksheets("Hoja2")
 
 
End Sub
'
'Cerrar formulario
Private Sub CommandButton2_Click() 'borrar
ingreso.Value = Clear
ListBox1.Value = Clear
TextBox1.Value = Clear
Me.Height = 48.75
'Unload Me
End Sub
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder