, Notepad, vbHide vbNormalFocus Shell:
Dim strCmd = "C:\WINDOWS\notepad.exe C:\Users\bgyona02\Desktop\OLAttachments\" & LatestFile
MyFile = Shell(strCmd, vbHide)
, SendKeys ....
, , , FileSystemObject Notepad.exe?
Option Explicit
Const FOR_READING = 1
Sub LoadTextFile()
Dim varTxtContent As Variant
Dim intLine As Integer
'Debug.Print GetTextFileContent("D:\temp.txt")
varTxtContent = Split(GetTextFileContent("D:\temp.txt"), vbCr, -1, vbBinaryCompare)
For intLine = 0 To UBound(varTxtContent) - 1
ThisWorkbook.Worksheets("Sheet1").Range("B" & intLine + 1).Value = varTxtContent(intLine)
Next intLine
End Sub
Function GetTextFileContent(strPath As String) As String
Dim strContent As String
Dim objFso As Object
Dim objFile As Object
Dim objStream As Object
strContent = ""
On Error GoTo CleanUp:
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objFile = objFso.GetFile(strPath)
Set objStream = objFile.OpenAsTextStream(FOR_READING, 0)
With objStream
strContent = .ReadAll
.Close
End With
CleanUp:
Set objStream = Nothing
Set objFile = Nothing
Set objFso = Nothing
GetTextFileContent = strContent
End Function
, . :
â, î or ô
foo
bar foo
baz bar foo
, Application.ScreenUpdating Excel, , Windows. , - , , - Windows API. FileSystemObject , .
.