vba [vba] VBA 외부 TXT 값 불러오기
페이지 정보
본문
Sub program1472_com()
Const FullPath As String = "C:\DATA\AAA.TXT"
Dim V As Variant, i As Integer
If Len(Dir(FullPath)) > 0 Then
V = ReadText(FullPath)
Do While InStr(V, Space(2)) > 0
V = Replace(V, Space(2), Space(1))
Loop
For Each V In Split(V, vbCrLf)
With CreateObject("new:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
.SetText Join(Split(V, Space(1)), vbTab)
.PutInClipboard
End With
ActiveSheet.Paste Destination:=Cells(Rows.Count, "A").End(3)(2)
Next
End If
End Sub
Public Function ReadText(Optional FilePath As String = "") As String
If Len(Dir$(FilePath)) = 0 Then Exit Function
Dim FN As Integer, tmp() As Byte
FN = FreeFile
ReDim tmp(FileLen(FilePath) - 1) As Byte
Open FilePath For Binary As #FN
Get #FN, , tmp
Close #FN
ReadText = StrConv(tmp, vbUnicode)
End Function
- 이전글[vba] Window API 를 이용한 Clipboard 의 Bitmap 저장하기 19.09.29
- 다음글[vba] MSXML2.XMLHTTP.6.0 을 이용한 https://kr.investing.com/ 사이트의 443 포트 크롤링 19.09.28
댓글목록
등록된 댓글이 없습니다.