Pagina 2 di 2 primaprima 1 2
Visualizzazione dei risultati da 11 a 14 su 14

Discussione: Da Excel a Txt

  1. #11
    Utente di HTML.it L'avatar di darkblOOd
    Registrato dal
    Jul 2001
    Messaggi
    2,212

    unisce due file di excel

    codice:
    Option Explicit
    Dim xlApp(1 To 2) As Excel.Application
    Dim xlWkB As Excel.Workbook
    Dim LastCellSorgente As String
    Dim LastCellDest As String
    Dim RIGA As String
    Dim a
    
    Private Sub cmdAccoda_Click()
    If txtFileSorgente = "" Then
        MsgBox "Indicare il file sorgente", vbExclamation, Me.Caption
        txtFileSorgente.SetFocus
        Exit Sub
    End If
    If txtFileDestinazione = "" Then
        MsgBox "Indicare il file di destinazione", vbExclamation, Me.Caption
        txtFileDestinazione.SetFocus
        Exit Sub
    End If
    Me.MousePointer = 11
    'File Sorgente
    Set xlApp(1) = New Excel.Application
    xlApp(1).DisplayAlerts = False
    'File Destinazione
    Set xlApp(2) = New Excel.Application
    Set xlWkB = xlApp(2).Workbooks.Open(txtFileDestinazione)
    xlApp(1).Workbooks.Open (txtFileSorgente)
    LastCellSorgente = xlApp(1).ActiveCell.SpecialCells(xlCellTypeLastCell).Address
    LastCellSorgente = Replace(LastCellSorgente, "$", "")
    LastCellDest = xlApp(2).ActiveCell.SpecialCells(xlCellTypeLastCell).Address
    RIGA = Mid(LastCellDest, (InStrRev(LastCellDest, "$") + 1))
    xlApp(1).Range("A1:" & LastCellSorgente).Copy
    If RIGA = 1 Then
        xlApp(2).Range("A" & RIGA).PasteSpecial xlPasteValues
    Else
        xlApp(2).Range("A" & (RIGA + 1)).PasteSpecial xlPasteValues
    End If
    xlApp(1).Quit
    xlApp(2).Range("A1").Activate
    xlWkB.Close (True)
    xlApp(2).Quit
    Set xlApp(1) = Nothing
    Set xlApp(2) = Nothing
    Me.MousePointer = 0
    MsgBox "Operazione terminata", , Me.Caption
    End Sub
    
    Private Sub cmdEsci_Click()
    End
    End Sub
    
    Private Sub cmdFileSorgente_Click()
    cdApriFile.ShowOpen
    txtFileSorgente = cdApriFile.FileName
    End Sub
    
    Private Sub Command1_Click()
    cdApriFile.ShowOpen
    txtFileDestinazione = cdApriFile.FileName
    End Sub

  2. #12
    Utente di HTML.it L'avatar di darkblOOd
    Registrato dal
    Jul 2001
    Messaggi
    2,212

    scrivi su celle di excel

    codice:
    Option Explicit
    Dim xlApp As Excel.Application
    Dim xlWkB As Excel.Workbook
    Dim xlWkS As Excel.Worksheet
    Dim str As String
    
    Private Sub cmdApri_Click()
    cdFile.ShowOpen
    txtFile = cdFile.FileName
    End Sub
    
    Private Sub cmdEsci_Click()
    End
    End Sub
    
    Private Sub Command1_Click()
    Me.MousePointer = 11
    Set xlApp = New Excel.Application
    xlApp.Workbooks.Open (txtFile)
    str = xlApp.ActiveCell.SpecialCells(xlCellTypeLastCell).Address
    str = Replace(str, "$", " ")
    txtCella = str
    Dim x As Integer
    For x = 1 To 56
    xlApp.Range("a" & x).Interior.ColorIndex = x
    Next x
    xlApp.DisplayAlerts = False
    xlApp.Quit
    Set xlApp = Nothing
    Me.MousePointer = 0
    End Sub

  3. #13
    Utente di HTML.it L'avatar di darkblOOd
    Registrato dal
    Jul 2001
    Messaggi
    2,212
    studiati sti 2 programmini, ti dico subito che non fanno quello che vorresti, ma puoi arrivare a leggere un file di excel, basta modificare il codice e dirgli di scrivere ciò che leggi su un file di testo

  4. #14
    poi ti consiglio di usare il registratore di macro che in exel
    genera automaticamente il codice che poi puoi osservare modificare e importare

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.