jevi
Active Member
- Joined
- Apr 13, 2010
- Messages
- 339
- Office Version
- 2016
- Platform
- Windows
Hi All,
I have this macro which a collegue of mine did but I have to upload one by one the txt written the name in the box, but I would like that I can upload all the files TXT that are in the folder in the word document with this macro.
So the modification that I need is to upload the TXT files all at once and not one by one. Is there a way to do it?
Thank you,
I have this macro which a collegue of mine did but I have to upload one by one the txt written the name in the box, but I would like that I can upload all the files TXT that are in the folder in the word document with this macro.
So the modification that I need is to upload the TXT files all at once and not one by one. Is there a way to do it?
Thank you,
SQL:
Sub ImportaFileFcFc()
Dim file, riga, fc, riga1 As String
Dim count, maxRow As Integer
count = 0
maxRow = 60 ' Max Row per page
file = InputBox("Nome File", "Nome file")
If (file <> "") Then
If InStr(1, file, ":", vbTextCompare) > 0 Then
Open file For Input As #1
Else
Open ActiveDocument.Path & "\" & file For Input As #1
End If
Else
Return
End If
With ActiveDocument.Paragraphs(1)
.LineSpacingRule = wdLineSpaceExactly
.LineSpacing = 11
End With
Do While Not EOF(1)
Line Input #1, riga
fc = Mid(riga, 1, 1)
riga1 = Mid(riga, 2, Len(riga))
' VALORI PER *FCFC
' Blank = Avanza stampa di 1 rigo
' Zero = Avanza stampa di 2 righi
' Meno = Avanza stampa di 3 righi
' Più = Avanza stampa di zero righe
' Uno = Salto a riga uno
Select Case fc
Case " "
count = count + 1
Selection.TypeText (vbCr)
Selection.TypeText (riga1)
Case "0"
count = count + 2
Selection.TypeText (vbCr)
Selection.TypeText (vbCr)
Selection.TypeText (riga1)
Case "-"
count = count + 3
Selection.TypeText (vbCr)
Selection.TypeText (vbCr)
Selection.TypeText (vbCr)
Selection.TypeText (riga1)
Case "+"
count = count + 0
Selection.TypeText (riga1)
Case "1"
count = 1
Selection.InsertBreak Type:=wdPageBreak
'Selection.TypeText (vbCr)
Selection.TypeText (riga1)
End Select
Loop
Close #1 ' Chiude il file.
End Sub