Created
March 18, 2020 06:41
-
-
Save msakai/b6ed009d54d2d2505dd393d5d3e081bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'win32ole' | |
ex = WIN32OLE.new("Excel.Application") | |
fso = WIN32OLE.new("Scripting.FileSystemObject") | |
files = ["Book1.xlsx", "Book2.xlsx"] | |
book = ex.Workbooks.Add | |
files.each { |file| | |
file = fso.GetAbsolutePathName(file) | |
book1 = ex.Workbooks.Open(file) | |
book1.Sheets(1).Copy(After: book.Sheets(book.Sheets.Count)) | |
book1.Close | |
} | |
book.Sheets(1).Delete | |
book.SaveAs("C:\\Users\\sakai\\Documents\\test.xlsx") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment