hi all !
i have a script is read the xls first ---> second read the text and write the text information to excel
i know the excel vba can open the text file for input for
e.g
If InStr(var1, "abc") > 0 Then
Cells(I, 6) = Mid$(var1, 11, 6)
I = I + 1
End If
now i had two problem
1: can't write everything from txt file to excel file
2:if i run the script ; it will be go to the last row ; but if i msgbox the substr is nothing problem ....
what going wrong ?
please help me fix the bug thank.....
my code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Sub2:
settimer, showprogress1, 600
FileSelectFile, filepath, 3, , Open a file, xls Documents (*.xls;)
if filepath =
{
MsgBox, Didn't select anything.
return
}
objExcel := ComObjCreate("Excel.Application")
objExcel.Workbooks.Open(filepath)
objExcel.Visible := false
Wrkbk := objExcel.ActiveWorkbook
lastrow:= objExcel.Range("A" objExcel.Rows.Count).End(xlUp := -4162).Row
i=2
Loop
{
strid := objExcel.Cells(i, 1).text
strlev := objExcel.Cells(i, 2).text
strtarget := objExcel.Cells(i, 3).text
if (strid =""){
MsgBox, 0, level transfer , DONE!
objExcel.ActiveWorkbook.saved := ture
Process, close, Excel.exe
return
}
Loop
{
FileRead, OutputVar, C:\Users\Desktop\OLD\0000319891.txt
char:="DATE :"
if InStr(OutputVar, char)
StringGetPos, pos, OutputVar, %char%
;MsgBox % SubStr(OutputVar, pos, 19)
objExcel.Cells(i, 4).value:= SubStr(OutputVar, pos, 19) <-----------this is my write excel code ; but it not working
break
}
i:=i+1
}
sleep, 500
Process, Exist, Excel.exe
MsgBox % ErrorLevel?"Excel Process is active":"Excel Process is not active"
showprogress1:
existprogress:=i
Progress, zh0 x20 y20 b w100 fs ct0000FF cw00FF00, ,%existprogress%/%lastrow%
return
how to read .txt file and output to excel like vba
-
- Posts: 11
- Joined: 02 Oct 2017, 02:24
-
- Posts: 11
- Joined: 02 Oct 2017, 02:24
Re: how to read .txt file and output to excel like vba
please help ........
Re: how to read .txt file and output to excel like vba
Try this. Use a MsgBox to confirm that the file contents have been successfully read.
FileRead may be failing if the path doesn't exist.
Code: Select all
FileRead, OutputVar, C:\Users\Desktop\OLD\0000319891.txt
MsgBox, % OutputVar
;try these instead:
;FileRead, OutputVar, % "C:\Users\" A_UserName "\Desktop\OLD\0000319891.txt"
;FileRead, OutputVar, % A_Desktop "\OLD\0000319891.txt"
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: how to read .txt file and output to excel like vba
dear sir
i can't write from text file to excel
Do u have example use ahk to read the text file and write to excel ?
i can't write from text file to excel
Do u have example use ahk to read the text file and write to excel ?
Who is online
Users browsing this forum: Bing [Bot], luvini and 151 guests