I've tried to PM a couple guys here and commission them to code some tasks for me, but there has been some miscommunication, so i'll take a stab at trying to figure this out myself. I do appreciate the time and suggestions they offered if they're reading this. I used the search feature but still struggling to figure out how to assemble all this.
I'm running Windows 7 and Excel 2013, both 64bit. I need to copy text/values from one (temporarily opened) excel file to another (constantly open/active/maximized). One file (Temp) sits in an active/maximized folder at Windows taskbar #1 position. The other one (Perm) is active /maximized at Windows taskbar #2 position. I want the script to open the "Temp" file, copy text values from two specific worksheet (Sheet1) cells (A1, B1), and paste into "Perm" file specific worksheet (Sheet1) cells (A1, B1), and then delete the "Temp" file in folder at Windows taskbar #1 position. The Temp file is basically a product of Excel reports generated by third party software which always differ in file name and values. If I can direct AHK to open any existing (regardless of name) xlsx file in the Windows folder and delete, that would be great. I'm able to do this using keystrokes in AHK, but i'm looking to integrate a smoother (hopefully faster) COM type solution.
Copy cell values between Excel files without keystrokes
Copy cell values between Excel files without keystrokes
Last edited by hidefguy on 24 Jan 2018, 22:07, edited 3 times in total.
- FanaticGuru
- Posts: 1908
- Joined: 30 Sep 2013, 22:25
Re: Copy cell values between Excel files without keystrokes
Here is a start:
This will show you how to open two Excel files and copy a value from one cell to another.
Hopefully this will get you started. How you accomplish this now with keystrokes has no bearing and is not very useful in how you can do it with COM.
When asking for help, instead of showing how you do it now with keystrokes it would probably be more productive to just ask what you want moved from where, to where.
FG
Code: Select all
; Open new instance of Excel and show it
xlApp := ComObjCreate("Excel.Application")
xlApp.Visible := true
; Define the paths to two Excel files (used A_Desktop to point to the files on my computer but could use absolute paths)
FileFrom_Path := A_Desktop "\Test\Test1.xlsx"
FileTo_Path := A_Desktop "\Test\Test2.xlsx"
; Open two Excel files
FileFrom := xlApp.Workbooks.Open(FileFrom_Path)
FileTo := xlApp.Workbooks.Open(FileTo_Path)
; Make the value of the A2 cell on the second sheet of the "To" file equal to the value of the B3 cell on the first sheet of the "From" file
FileTo.Sheets(2).Range("A2").value := FileFrom.Sheets(1).Range("B3").value
Hopefully this will get you started. How you accomplish this now with keystrokes has no bearing and is not very useful in how you can do it with COM.
When asking for help, instead of showing how you do it now with keystrokes it would probably be more productive to just ask what you want moved from where, to where.
FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
Re: Copy cell values between Excel files without keystrokes
Thanks again FG. I'll play around with it
Re: Copy cell values between Excel files without keystrokes
Code: Select all
xlApp := ComObjActive("Excel.Application")
xlApp.Visible := true
FileFrom_Path := A_Desktop "\Folder\Temp.xlsx"
FileTo_Path := A_Desktop "\Perm.xlsx"
FileFrom := xlApp.Workbooks.Open(FileFrom_Path)
FileTo := xlApp.Workbooks.Open(FileTo_Path)
FileTo.Sheets(1).Range("A2").value := FileFrom.Sheets(2).Range("D4").value
FileTo.Sheets(1).Range("B2").value := FileFrom.Sheets(2).Range("I4").value
- FanaticGuru
- Posts: 1908
- Joined: 30 Sep 2013, 22:25
Re: Copy cell values between Excel files without keystrokes
Here is an example of how to loop through all of a certain type files in a folder.hidefguy wrote:Is there a way to access the xlsx file in the Folder without setting the \Folder\Temp.xlsx path by looking for just the file type? For example like \Folder\.xlsx.
Code: Select all
FileFrom_Pattern := A_Desktop "\Test\*.xlsx"
Loop, Files, % FileFrom_Pattern
{
MsgBox % A_LoopFileLongPath
}
Code: Select all
xlApp := ComObjActive("Excel.Application")
xlApp.Visible := true
FileTo_Path := A_Desktop "\Perm.xlsx"
FileTo := xlApp.Workbooks.Open(FileTo_Path)
FileFrom_Pattern := A_Desktop "\Folder\*.xlsx"
Loop, Files, % FileFrom_Pattern
{
FileFrom := xlApp.Workbooks.Open(A_LoopFileFullPath)
FileTo.Sheets(1).Range("A1").OffSet(A_Index,0).value := FileFrom.Sheets(2).Range("D4").value
FileTo.Sheets(1).Range("B1").OffSet(A_Index,0).value := FileFrom.Sheets(2).Range("I4").value
FileFrom.Close()
}
The first files values into A2 & B2, then A3 & B3, then A4 & B4, etc.
FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
Re: Copy cell values between Excel files without keystrokes
Code: Select all
xlApp := ComObjActive("Excel.Application")
xlApp.Visible := true
FileTo_Path := A_Desktop "\Perm.xlsx"
FileTo := xlApp.Workbooks.Open(FileTo_Path)
FileFrom_Pattern := A_Desktop "\Test\1.xlsx"
Loop, Files, % FileFrom_Pattern
{
FileFrom := xlApp.Workbooks.Open(A_LoopFileFullPath)
FileTo.Sheets(1).Range("G1").OffSet(A_Index,0).value := FileFrom.Sheets(2).Range("D4").value
FileTo.Sheets(1).Range("H1").OffSet(A_Index,0).value := FileFrom.Sheets(2).Range("I4").value
FileFrom.Close()
}
FileFrom_Pattern := A_Desktop "\Test\2.xlsx"
Loop, Files, % FileFrom_Pattern
{
FileFrom := xlApp.Workbooks.Open(A_LoopFileFullPath)
FileTo.Sheets(1).Range("I1").OffSet(A_Index,0).value := FileFrom.Sheets(2).Range("I4").value
FileFrom.Close()
}
FileFrom_Pattern := A_Desktop "\Test\3.xlsx"
Loop, Files, % FileFrom_Pattern
{
FileFrom := xlApp.Workbooks.Open(A_LoopFileFullPath)
FileTo.Sheets(1).Range("J1").OffSet(A_Index,0).value := FileFrom.Sheets(2).Range("I4").value
FileFrom.Close()
}
ExitApp
- FanaticGuru
- Posts: 1908
- Joined: 30 Sep 2013, 22:25
Re: Copy cell values between Excel files without keystrokes
Code: Select all
xlApp := ComObjActive("Excel.Application") ; Excel must be running
FileTo_Path := A_Desktop "\Perm.xlsx"
FileTo := xlApp.Workbooks.Open(FileTo_Path)
FileFrom_Pattern := A_Desktop "\Test\*.xlsx"
Loop, Files, % FileFrom_Pattern
{
FileFrom := xlApp.Workbooks.Open(A_LoopFileFullPath)
if (A_Index = 1)
{
FileTo.Sheets(1).Range("G1").value := FileFrom.Sheets(2).Range("D4").value
FileTo.Sheets(1).Range("H1").value := FileFrom.Sheets(2).Range("I4").value
}
else
{
FileTo.Sheets(1).Range("G1").OffSet(0,A_Index).value := FileFrom.Sheets(2).Range("I4").value
}
FileFromFullPath := FileFrom.Path "\" FileFrom.Name
FileFrom.Close()
FileDelete, % FileFromFullPath
}
Each of the From files are deleted after data is copied from them.
FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
Re: Copy cell values between Excel files without keystrokes
Sweet! I’ll play around with it. I feel guilty for wasting your time with the guidance you’ve provided. At least let me make a donation to your favorite charity
Before the ComObjActive copy script/loop even starts I’ve been using send, # to bring up the windows at lower tab. #1 is the software and #2 is open Perm excel file.
I tried this instead:
WinActivate, Software
WinActivate, Microsoft Excel
Software works fine, but Excel doesn’t come up. Should I just stick with keystrokes, or continue with a COM solution?
Before the ComObjActive copy script/loop even starts I’ve been using send, # to bring up the windows at lower tab. #1 is the software and #2 is open Perm excel file.
I tried this instead:
WinActivate, Software
WinActivate, Microsoft Excel
Software works fine, but Excel doesn’t come up. Should I just stick with keystrokes, or continue with a COM solution?
- FanaticGuru
- Posts: 1908
- Joined: 30 Sep 2013, 22:25
Re: Copy cell values between Excel files without keystrokes
If you change ComObjActive to ComObjCreate there is no reason to open Excel outside the script. This will cause the script to create an instance of Excel.hidefguy wrote:Sweet! I’ll play around with it. I feel guilty for wasting your time with the guidance you’ve provided. At least let me make a donation to your favorite charity
Before the ComObjActive copy script/loop even starts I’ve been using send, # to bring up the windows at lower tab. #1 is the software and #2 is open Perm excel file.
I tried this instead:
WinActivate, Software
WinActivate, Microsoft Excel
Software works fine, but Excel doesn’t come up. Should I just stick with keystrokes, or continue with a COM solution?
By default a new instance of Excel is not displayed and everything happens in the background. This is a little faster.
If you want to actual see Excel opening the workbooks and doing stuff you can do this:
Code: Select all
xlApp := ComObjCreate("Excel.Application")
xlApp.Visible := true
Code: Select all
FileTo.Save() ; save workbook
xlApp.DisplayAlerts := false ; don't display overwrite warning if file already exist
xlApp.Quit() ; close this instance of Excel
COM does not care if Excel windows are visible, minimized, positioned, active, what they are named, any of that. COM can detect all that stuff if a script needs to know but none of that is important to make AHK work with Excel through COM. Most COM scripts never reference or need anything about an Excel window.
A donation is not necessary but if you feel inclined you can donate to the AutoHotkey Foundation at the link below.
https://autohotkey.com/foundation/
Near the bottom of the page is a link to donate through PayPal.
FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
Re: Copy cell values between Excel files without keystrokes
That tested out well, and does specifically what I need. Can I substitute Range("G1"), Range("H1") to a function that references the first blank cell in column G, column H and so on? My Perm sheet will always have columns A-F pre-populated (manually) with values, before AHK automation is executed. The next G-H-I-etc... column blank cells can start on any given G row number. It's a constant continuation (day to day) and the Perm file is saved after completion of each AHK script.FanaticGuru wrote:This will open your Perm file and then all xlsx files in your Test folder one at a time. The first one copies values to the G1 and H1 cells. All the ones past the first are copied to a cell offset by an increasing amount to the right so you end up with data going into G1, H1, I1, J1, etc.
Each of the From files are deleted after data is copied from them.
FG
I tried the ComObjCreate, and I see what you mean. That's pretty swift.FanaticGuru wrote: If you change ComObjActive to ComObjCreate there is no reason to open Excel outside the script. This will cause the script to create an instance of Excel.
By default a new instance of Excel is not displayed and everything happens in the background. This is a little faster.
The assembled script will start/flow in some form of this, with software open at taskbar #1 window and Perm at taskbar #2 window. Except for the send, #, send, ^{ins} (copies Perm.xlsx column A value) keystrokes , the others are needed to manipulate the non-COM friendly software. I think the send, ^{V} (pastes Perm.xlsx column A value into software) might also be non-negotiable since it occurs within software. Be nice if I can convert the eligible keystrokes to COM capable commands. I can then just run the ComObjCreate with Excel in background, and let the software specific keystrokes do their thing.
send, #{1}
sleep, 500
send, {F6}
sleep, 500
send, {tab}
sleep, 500
send, {tab}
sleep, 500
send, #{2}
sleep, 500
send, ^{ins}
send, #{1}
sleep, 500
send, ^{V}
sleep, 500
send, ^!{enter}
sleep, 200
send, {enter}
sleep, 200
send, {esc}
sleep, 3000
send, {F8}
sleep, 1000
send, #{up}
sleep, 200
mouseclick, right
sleep, 200
send, {S}
sleep, 200
send, {enter}
sleep, 1000
send, {enter}
sleep, 1000
send, {enter}
sleep, 5000
send, !{F4}
sleep, 200
send, !{F4}
sleep, 200
send, #{2}
sleep, 200
xlApp := ComObjActive("Excel.Application")
FileTo_Path := A_Desktop "\Perm.xlsx"
FileTo := xlApp.Workbooks.Open(FileTo_Path)
FileFrom_Pattern := A_Desktop "\Test\*.xlsx"
Loop, Files, % FileFrom_Pattern
{
FileFrom := xlApp.Workbooks.Open(A_LoopFileFullPath)
if (A_Index = 1)
{
FileTo.Sheets(1).Range("G1").value := FileFrom.Sheets(2).Range("D4").value
FileTo.Sheets(1).Range("H1").value := FileFrom.Sheets(2).Range("I4").value
}
else
{
FileTo.Sheets(1).Range("G1").OffSet(0,A_Index).value := FileFrom.Sheets(2).Range("I4").value
}
FileFromFullPath := FileFrom.Path "\" FileFrom.Name
FileFrom.Close()
FileDelete, % FileFromFullPath
}
ExitApp
The AHK docs for FileDelete state that files get deleted from %A_WorkingDir%. Are they automatically wiped/ cleaned when I exit AHK, or is their some type of folder they build up in?FanaticGuru wrote: FileFromFullPath := FileFrom.Path "\" FileFrom.Name
FileFrom.Close()
FileDelete, % FileFromFullPath
Definitely plan on making a sizable donation. Have made some huge strides in just two days with your help. Your commitment to this AHK community is beyond noble.FanaticGuru wrote: A donation is not necessary but if you feel inclined you can donate to the AutoHotkey Foundation at the link below.
https://autohotkey.com/foundation/
Near the bottom of the page is a link to donate through PayPal.
FG
Last edited by hidefguy on 25 Jan 2018, 02:23, edited 1 time in total.
Re: Copy cell values between Excel files without keystrokes
Hi again FG. I'm attempting the above scenario, but with additional column values, and after first file opens/completes, want only column values I4,I6,I8,I10,I12 from subsequent files to populate to the right, remaining row cells, five cells at a time. I tried this below, and changing around A_Index value, plus a few other things. First file opens/copies fine, but no luck with subsequent ones. Searched around here and confused myself.FanaticGuru wrote:This will open your Perm file and then all xlsx files in your Test folder one at a time. The first one copies values to the G1 and H1 cells. All the ones past the first are copied to a cell offset by an increasing amount to the right so you end up with data going into G1, H1, I1, J1, etc.Code: Select all
xlApp := ComObjActive("Excel.Application") ; Excel must be running FileTo_Path := A_Desktop "\Perm.xlsx" FileTo := xlApp.Workbooks.Open(FileTo_Path) FileFrom_Pattern := A_Desktop "\Test\*.xlsx" Loop, Files, % FileFrom_Pattern { FileFrom := xlApp.Workbooks.Open(A_LoopFileFullPath) if (A_Index = 1) { FileTo.Sheets(1).Range("G1").value := FileFrom.Sheets(2).Range("D4").value FileTo.Sheets(1).Range("H1").value := FileFrom.Sheets(2).Range("I4").value } else { FileTo.Sheets(1).Range("G1").OffSet(0,A_Index).value := FileFrom.Sheets(2).Range("I4").value } FileFromFullPath := FileFrom.Path "\" FileFrom.Name FileFrom.Close() FileDelete, % FileFromFullPath }
Each of the From files are deleted after data is copied from them.
FG
Code: Select all
Loop, Files, % FileFrom_Pattern
{
FileFrom := xlApp.Workbooks.Open(A_LoopFileFullPath)
if (A_Index = 1)
{
FileTo.Sheets(1).Range("G1").value := FileFrom.Sheets(2).Range("D4").value
FileTo.Sheets(1).Range("H1").value := FileFrom.Sheets(2).Range("I4").value
FileTo.Sheets(1).Range("I1").value := FileFrom.Sheets(2).Range("I6").value
FileTo.Sheets(1).Range("J1").value := FileFrom.Sheets(2).Range("I8").value
FileTo.Sheets(1).Range("K1").value := FileFrom.Sheets(2).Range("I10").value
FileTo.Sheets(1).Range("L1").value := FileFrom.Sheets(2).Range("I12").value
}
else
{
FileTo.Sheets(1).Range("L1").Offset(0,A_Index).value := FileFrom.Sheets(2).Range("I4:I12").value
}
FileFromFullPath := FileFrom.Path "\" FileFrom.Name
FileFrom.Close()
FileDelete, % FileFromFullPath
}
- FanaticGuru
- Posts: 1908
- Joined: 30 Sep 2013, 22:25
Re: Copy cell values between Excel files without keystrokes
FileTo.Sheets(1).Range("L1").Offset(0,A_Index).value := FileFrom.Sheets(2).Range("I4:I12").value
In the above the Ranges are not the same size. The Ranges have to be the same size like below.
FileTo.Sheets(1).Range("L1:L9").Offset(0,A_Index).value := FileFrom.Sheets(2).Range("I4:I12").value
If you don't want the whole range then you are going to have to do it more manually.
You could do another loop here with some math to replace those 5 lines with 2 lines but probably not worth the trouble.
FG
In the above the Ranges are not the same size. The Ranges have to be the same size like below.
FileTo.Sheets(1).Range("L1:L9").Offset(0,A_Index).value := FileFrom.Sheets(2).Range("I4:I12").value
If you don't want the whole range then you are going to have to do it more manually.
Code: Select all
FileTo.Sheets(1).Range("L1").Offset(0,A_Index).value := FileFrom.Sheets(2).Range("I4").value
FileTo.Sheets(1).Range("L2").Offset(0,A_Index).value := FileFrom.Sheets(2).Range("I6").value
FileTo.Sheets(1).Range("L3").Offset(0,A_Index).value := FileFrom.Sheets(2).Range("I8").value
FileTo.Sheets(1).Range("L4").Offset(0,A_Index).value := FileFrom.Sheets(2).Range("I10").value
FileTo.Sheets(1).Range("L5").Offset(0,A_Index).value := FileFrom.Sheets(2).Range("I12").value
FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
Re: Copy cell values between Excel files without keystrokes
Thanks for the tips. The FileFrom columnar values of I4-I12 I actually want populated horizontally in a row with same pattern as first file like so from second file:
FileTo.Sheets(1).Range("M1").Offset(0,A_Index).value := FileFrom.Sheets(2).Range("I4").value
FileTo.Sheets(1).Range("N1").Offset(0,A_Index).value := FileFrom.Sheets(2).Range("I6").value
FileTo.Sheets(1).Range("O1").Offset(0,A_Index).value := FileFrom.Sheets(2).Range("I8").value
FileTo.Sheets(1).Range("P1").Offset(0,A_Index).value := FileFrom.Sheets(2).Range("I10").value
FileTo.Sheets(1).Range("Q1").Offset(0,A_Index).value := FileFrom.Sheets(2).Range("I12").value
and third file like so
FileTo.Sheets(1).Range("R1").Offset(0,A_Index).value := FileFrom.Sheets(2).Range("I4").value
FileTo.Sheets(1).Range("S1").Offset(0,A_Index).value := FileFrom.Sheets(2).Range("I6").value
FileTo.Sheets(1).Range("T1").Offset(0,A_Index).value := FileFrom.Sheets(2).Range("I8").value
FileTo.Sheets(1).Range("U1").Offset(0,A_Index).value := FileFrom.Sheets(2).Range("I10").value
FileTo.Sheets(1).Range("V1").Offset(0,A_Index).value := FileFrom.Sheets(2).Range("I12").value
and so on for remaining files.......
FileTo.Sheets(1).Range("M1").Offset(0,A_Index).value := FileFrom.Sheets(2).Range("I4").value
FileTo.Sheets(1).Range("N1").Offset(0,A_Index).value := FileFrom.Sheets(2).Range("I6").value
FileTo.Sheets(1).Range("O1").Offset(0,A_Index).value := FileFrom.Sheets(2).Range("I8").value
FileTo.Sheets(1).Range("P1").Offset(0,A_Index).value := FileFrom.Sheets(2).Range("I10").value
FileTo.Sheets(1).Range("Q1").Offset(0,A_Index).value := FileFrom.Sheets(2).Range("I12").value
and third file like so
FileTo.Sheets(1).Range("R1").Offset(0,A_Index).value := FileFrom.Sheets(2).Range("I4").value
FileTo.Sheets(1).Range("S1").Offset(0,A_Index).value := FileFrom.Sheets(2).Range("I6").value
FileTo.Sheets(1).Range("T1").Offset(0,A_Index).value := FileFrom.Sheets(2).Range("I8").value
FileTo.Sheets(1).Range("U1").Offset(0,A_Index).value := FileFrom.Sheets(2).Range("I10").value
FileTo.Sheets(1).Range("V1").Offset(0,A_Index).value := FileFrom.Sheets(2).Range("I12").value
and so on for remaining files.......
- FanaticGuru
- Posts: 1908
- Joined: 30 Sep 2013, 22:25
Re: Copy cell values between Excel files without keystrokes
Maybe this will work for you.
Untested.
FG
Code: Select all
Col := 5 ; starting column
Loop, Files, % FileFrom_Pattern
{
FileFrom := xlApp.Workbooks.Open(A_LoopFileFullPath)
if (A_Index = 1)
{
FileTo.Sheets(1).Cells(1,Col).value := FileFrom.Sheets(2).Range("D4").value
Col++
}
for index, Address in ["I4","I6","I8","I10","I12"]
{
FileTo.Sheets(1).Cells(1,Col).value := FileFrom.Sheets(2).Range(Address).value
Col++
}
FileFromFullPath := FileFrom.Path "\" FileFrom.Name
FileFrom.Close()
FileDelete, % FileFromFullPath
}
FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
Re: Copy cell values between Excel files without keystrokes
Dude, you're the best. That worked perfectly. I should have been more precise in my initial post today. I posted a generic example that flows with your past sample code, but I was able to modify your code above. The script I run actually has an input for a starting row (@) followed by offsets, so I just did this, and followed down along the columns using snippets of this attaching the offsets:
Col := 5
Loop, Files, % FileFrom_Pattern
{
FileFrom := xlApp.Workbooks.Open(A_LoopFileFullPath)
if (A_Index = 1)
{
FileTo.Sheets(1).Cells(@,Col).value := FileFrom.Sheets(2).Range("D4").value
Col++
}
for index, Address in ["I4","I6","I8","I10","I12"]
{
FileTo.Sheets(1).Cells(@,Col).value := FileFrom.Sheets(2).Range(Address).value
Col++
}
FileFromFullPath := FileFrom.Path "\" FileFrom.Name
FileFrom.Close()
FileDelete, % FileFromFullPath
}
Col := 5
Loop, Files, % FileFrom_Pattern
{
FileFrom := xlApp.Workbooks.Open(A_LoopFileFullPath)
if (A_Index = 1)
{
FileTo.Sheets(1).Cells(@,Col).value := FileFrom.Sheets(2).Range("D4").value
Col++
}
for index, Address in ["I4","I6","I8","I10","I12"]
{
FileTo.Sheets(1).Cells(@,Col).value := FileFrom.Sheets(2).Range(Address).value
Col++
}
FileFromFullPath := FileFrom.Path "\" FileFrom.Name
FileFrom.Close()
FileDelete, % FileFromFullPath
}
Who is online
Users browsing this forum: JoeWinograd, metallizer, Rohwedder, typerd92 and 110 guests