
Option Explicit
Sub Esporta_TXT()
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''' ATTENZIONE RICHIEDE L'ATTIVAZIONE DELLA LIBRERIA MICROSOFT SCRIPTING RUNTIME '''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim wbPFV As Workbook
Dim wsPFV As Worksheet, wsData As Worksheet
Dim objFSYS As FileSystemObject 'leggasi sopra, attiva la libreria
Dim objTxt As TextStream 'Tipo per file di testo
Dim strTxt As String, strData As String
Dim x As Long, i As Long
Set objFSYS = New FileSystemObject
Set wbPFV = ThisWorkbook
Set wsPFV = wbPFV.Sheets("Per Upload")
Set wsData = wbPFV.Sheets("Riepilogo")
strData = Format(wsData.Cells(2, 5), "dd-mm-yyyy")
Set objTxt = objFSYS.CreateTextFile(wbPFV.Path & "CAPITALE PRIMARIO al " & strData & ".txt", True) 'creo file txt, sovrascrivo precedenti
With wsPFV
x = .Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To x
strTxt = .Cells(i, 1).Text
If strTxt = "" Then strTxt = "-"
With objTxt
.Write strTxt
.Write vbNewLine
End With
Next i
End With
Call Shell("explorer.exe " & wbPFV.Path, vbNormalFocus)
Set wbPFV = Nothing
Set wsPFV = Nothing
Set wsData = Nothing
Set objTxt = Nothing
End Sub
|
Option Explicit
Sub Esporta_TXT()
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''' ATTENZIONE RICHIEDE L'ATTIVAZIONE DELLA LIBRERIA MICROSOFT SCRIPTING RUNTIME '''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim wbPFV As Workbook
Dim wsPFV As Worksheet, wsData As Worksheet
Dim objFSYS As FileSystemObject 'leggasi sopra, attiva la libreria
Dim objTxt As TextStream 'Tipo per file di testo
Dim strTxt As String, strData As String
Dim x As Long, i As Long
Set objFSYS = New FileSystemObject
Set wbPFV = ThisWorkbook
Set wsPFV = wbPFV.Sheets("Foglio1")
With wsPFV
x = .Range("F" & Rows.Count).End(xlUp).Row
For i = 2 To x
Set objTxt = objFSYS.CreateTextFile(wbPFV.Path & "V" & i - 1 & ".txt", True) 'creo file txt, sovrascrivo precedenti
strTxt = .Cells(i, 6).Text
If strTxt = "" Then strTxt = "-"
With objTxt
.Write strTxt
End With
Next i
End With
Call Shell("explorer.exe " & wbPFV.Path, vbNormalFocus)
Set wbPFV = Nothing
Set wsPFV = Nothing
Set wsData = Nothing
Set objTxt = Nothing
End Sub |
