USUÁRIO:      SENHA:        SALVAR LOGIN ?    Adicione o VBWEB na sua lista de favoritos   Fale conosco 

 

  Fórum

  Visual Basic
Voltar
Autor Assunto:  Exportar GRID para o Excel
Juliana T.
SÃO PAULO
SP - BRASIL
ENUNCIADA !
Postada em 15/09/2008 18:11 hs         

Private Sub Excel()
   Me.MousePointer = vbHourglass
        
    Set cn = New ADODB.Connection
    Set rs = New ADODB.Recordset
    Set exclApp = CreateObject("Excel.Application")
               Set exclsheet = CreateObject("Excel.Sheet")
               Set exclBook = exclApp.Workbooks.Add
               Set exclsheet = exclBook.Worksheets(1)
               
     With MS1
            .FixedCols = 0
            .Rows = .Rows
   
    i = 0
    l = 0
   
    exclsheet.Rows(1).Font.Bold = True
      
         For i = 0 To .Rows
         l = l + 1
         'If .TextMatrix(l, 3) = a Then
            'Exit Sub
            'Me.MousePointer = vbArrow
         'Else
               exclsheet.Cells(l, 1).Value = .TextMatrix(i, 0)
               exclsheet.Cells(l, 2).Value = .TextMatrix(i, 1)
               exclsheet.Cells(l, 3).Value = .TextMatrix(i, 2)
               exclsheet.Cells(l, 4).Value = .TextMatrix(i, 3)
               exclsheet.Cells(l, 5).Value = .TextMatrix(i, 4)
               exclsheet.Cells(l, 6).Value = .TextMatrix(i, 5)
               exclsheet.Cells(l, 7).Value = .TextMatrix(i, 6)
        ' End If
        
        
         Next
               
                exclsheet.SaveAs "C:Sera" & Format(Now, "DDMMYYHHMM") & ".xls"
                exclApp.Application.Quit
                Set excelSheet = Nothing
                MsgBox "ARQUIVO SALVO COMO : " & vbNewLine & "C:Sera" & Format(Now, "DDMMYYHHMM") & ".xls", vbInformation, "AVISO"
                Set exclsheet = Nothing
                Set exclBook = Nothing
                Set exclApp = Nothing

End With
Me.MousePointer = vbArrow

End Sub

 
   
DeFreitas
SÃO PAULO
SP - BRASIL
ENUNCIADA !
Postada em 17/09/2008 08:34 hs            
Bom dia, Juliana.
 
Vejamos. Faça a seguinte alteração no seu código:
 
For i = 0 To .Rows ---> For i = 0 To .Rows - 1
 
Teste e nos diga se funcionou.
 
Desculpe a demora.
 
 
 
 
   
Juliana T.
SÃO PAULO
SP - BRASIL
ENUNCIADA !
Postada em 17/09/2008 11:30 hs         
Deu certooo =)
OBRIGADAAAAAAAAAAA
   
SRICK
não registrado
ENUNCIADA !
Postada em 19/11/2008 13:29 hs   
Juliana, será que você poderia me enviar este programa para mim estudá-lo?

Desde já agradeço..

Henrique
   
Macaubal
MACAUBAL
SP - BRASIL
Postada em 19/11/2008 15:18 hs            
A funcao abaixo vai criar um arquivo em CSV que pode ser aberto no excell, basta voce ir definindo as posicoes caso queira.
 
For X = 0 To Grid.Rows - 1
    For Y = 0 To Grid.Cols - 1
        LS_Msg = LS_Msg & Grid.TextMatrix(X, Y) & ";"
        DoEvents
    Next Y
    LS_Msg = LS_Msg & vbCrLf
    DoEvents
Next X
 
    Open "c:arquivo.csv" For Output As FreeFile
    Print #1, LS_Msg
    Close #1
     
Juliana T.
SÃO PAULO
SP - BRASIL
ENUNCIADA !
Postada em 19/11/2008 15:24 hs         
Henrique, eu estava fazendo um teste, não tenho mais esse programa.
   
Página(s): 2/2     « ANTERIOR  


Seu Nome:

Seu eMail:

ALTERAR PARA MODO HTML
Mensagem:

[:)] = 
[:P] = 
[:(] = 
[;)] = 

HTML DESLIGADO

     
 VOLTAR

  



CyberWEB Network Ltda.    © Copyright 2000-2024   -   Todos os direitos reservados.
Powered by HostingZone - A melhor hospedagem para seu site
Topo da página