ALGUIEN ME PUEDE AYUDAR?
Publicado por Josetxo (1 intervención) el 24/10/2003 11:55:22
Hola
Es la primera vez que hago esto, quiero crear un archivo excel pasandole datos desde VB tengo el siguiente codigo, me llega a pedir el nombre del achivo, y me abre la hoja excel, pero no me pone los datos en las columnas ni me crea el archivo.
Option Explicit
Const NONE = 0, MANUAL = 2
Dim ExcelRunning As Boolean
Private Sub command1_click(index As Integer)
Dim Cmd As String
Dim Filename As String
Dim Prompt As String
Dim X As Long
Dim Item As String
Static Row As Integer
On Local Error GoTo Errorhandler
Select Case index
Case 0 'siguiente
If Not ExcelRunning Then
'se inicia excel minimizado sin foco. asegurate de colocar aqui la ruta a tu copia de excel
X = Shell("C:\office 97\office\excel.exe", vbMinimizedNoFocus)
ExcelRunning = True
End If
'introduce el dato en la hoja de calculo excel. hace un bucle para cada text bos del grupo de controles.
'excel siempre se inicia con el nombre de hoja de calculo por defecto sheet1.
Row = Row + 1
For X = 0 To 2
Text1(X).LinkMode = NONE
Text1(X).LinkTopic = "excell|sheet1"
Item = "R" & Right$(Str$(Row), Len(Str$(Row)) - 1)
Item = Item & "C" & Right$(Str$(X + 1), Len(Str$(X + 1)) - 1)
Text1(X).LinkItem = Item
Text1(X).LinkMode = MANUAL
Text1(X).LinkPoke
Next X
'borra las cajas de texto
For X = 0 To 2
Text1(X) = ""
Next X
Es la primera vez que hago esto, quiero crear un archivo excel pasandole datos desde VB tengo el siguiente codigo, me llega a pedir el nombre del achivo, y me abre la hoja excel, pero no me pone los datos en las columnas ni me crea el archivo.
Option Explicit
Const NONE = 0, MANUAL = 2
Dim ExcelRunning As Boolean
Private Sub command1_click(index As Integer)
Dim Cmd As String
Dim Filename As String
Dim Prompt As String
Dim X As Long
Dim Item As String
Static Row As Integer
On Local Error GoTo Errorhandler
Select Case index
Case 0 'siguiente
If Not ExcelRunning Then
'se inicia excel minimizado sin foco. asegurate de colocar aqui la ruta a tu copia de excel
X = Shell("C:\office 97\office\excel.exe", vbMinimizedNoFocus)
ExcelRunning = True
End If
'introduce el dato en la hoja de calculo excel. hace un bucle para cada text bos del grupo de controles.
'excel siempre se inicia con el nombre de hoja de calculo por defecto sheet1.
Row = Row + 1
For X = 0 To 2
Text1(X).LinkMode = NONE
Text1(X).LinkTopic = "excell|sheet1"
Item = "R" & Right$(Str$(Row), Len(Str$(Row)) - 1)
Item = Item & "C" & Right$(Str$(X + 1), Len(Str$(X + 1)) - 1)
Text1(X).LinkItem = Item
Text1(X).LinkMode = MANUAL
Text1(X).LinkPoke
Next X
'borra las cajas de texto
For X = 0 To 2
Text1(X) = ""
Next X
Valora esta pregunta


0