I have this code now, the sql comand (source) makes a query with som
parameters,
but how can I do for read a specific cell of an access table withou
pass it to an excel file?
Sub ConsultaDePrueba()
Dim strAngle As String
Dim rsTest As ADODB.Recordset
Dim cnTest As ADODB.Connection
Dim tabNueva As TableDef
Dim rowNuevo As Row
Dim fila As Integer
Dim appexcel As Excel.Application
Dim xlbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
Dim visDocument As Visio.Document
Dim NombreHoja As String
'On Error Resume Next 'no le para a los errores
Set visDocument = ActiveDocument
Set appexcel = CreateObject("excel.application")
appexcel.Visible = True
Filename = visDocument.Path + "Base1" 'NOMBRE DEL ARCHIV
EXCEL
NombreHoja = "hoja3"
appexcel.Workbooks.Open (Filename)
Set H1 = appexcel.Worksheets(NombreHoja)
Set cnTest = New ADODB.Connection
cnTest.Provider = "microsoft.jet.oledb.4.0"
cnTest.ConnectionString = "primerpaso.mdb" 'siempre busca en e
mismo directorio que se encuentra este proyecto
cnTest.Open
Set rsTest = New ADODB.Recordset
rsTest.ActiveConnection = cnTest
rsTest.Source = "select * from paso1 where angle = cint(5)"
'ojo solo acepta string en caso de usar numero convertir !
rsTest.CursorType = adOpenStatic
rsTest.LockType = adLockOptimistic
rsTest.Open
fila = 2
Do While Not rsTest.EOF = True
H1.Cells(fila, 1).Value = rsTest.Fields("angle")
'H1.Cells(2, 1).Value = rsTest.Fields("angle")
rsTest.MoveNext
fila = fila + 1
Loop
H1.Cells.EntireColumn.AutoFit 'para autoajustar el tamano de la
columnas
End Su