Dim ExcelApp As Excel.Application
Set ExcelApp = CreateObject("Excel.Application")
With ExcelApp
.Application.DisplayAlerts = False '抑制刪除警告提示訊息
.Workbooks.Open FileName:=App.Path + "\Sample.xls"
.Visible = True
.Workbooks.Open FileName:=strFileName + ".xls"
.Range("D" + CStr(i)).Select
strTmp = .ActiveCell.FormulaR1C1
.Range("A3:S" + CStr(i)).Select
.Selection.Copy
.Windows("Sample.xls").Activate
.Range("A" + CStr(m)).Select
.ActiveSheet.Paste
.Windows(FileName + ".xls").Close
.ActiveSheet.PageSetup.PrintArea = "$D$1:$K$" + CStr(m - 1)
.Columns("T:T").Select
.Selection.WrapText = True
'另存新檔
.ActiveWorkbook.SaveAs FileName:=App.Path + "\Merge.xls",FileFormat:=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
'關閉檔案
.ActiveWindow.Close
Set ExcelApp = Nothing
沒有留言:
張貼留言