vbscript 将表格导出到新工作簿

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vbscript 将表格导出到新工作簿相关的知识,希望对你有一定的参考价值。

Option Explicit

Public Sub ExportData()

Dim wbTarget As Workbook
Dim wbSource As Workbook

Dim wsRoutes As Worksheet
Dim wsCheckpoints As Worksheet
Dim wsAllowableValues As Worksheet

Dim sOpenFile As String







Set wbSource = ActiveWorkbook
Set wbTarget = Workbooks.Add
Application.DisplayAlerts = False
wbTarget.SaveAs Filename:="C:\Meridium\Rounds\ROUNDS_LOADER_SHEET.xls", FileFormat:=xlExcel7, ConflictResolution:=xlLocalSessionChanges




'Once we are saved, set thangs
Dim i As Integer
Dim sheets(1 To 3) As String

sheets(1) = sWSRoutes
sheets(2) = sWSCheckpointList
sheets(3) = sWSAllowableValues


'Copy the sheets we want to copy
For i = LBound(sheets) To UBound(sheets)

    wbSource.sheets(CStr(sheets(i))).Copy After:=wbTarget.sheets(i)
    
    With wbTarget
    
    .sheets(CStr(sheets(i))).Rows("1:3").Delete 'Range(.Cells(1, 1), .Cells(3, 1))
    
    
    End With

Next i


wbTarget.sheets("Sheet1").Delete
Application.DisplayAlerts = True
wbTarget.Close SaveChanges:=True




End Sub

以上是关于vbscript 将表格导出到新工作簿的主要内容,如果未能解决你的问题,请参考以下文章

vbscript 将整个工作簿导出为PDF

vbscript 使用文件对话框将工作簿导出为PDF

Excel:将工作簿复制到新工作簿

将 HTML 表格数据导出到现有工作簿中的新工作表(如果存在),否则更新现有工作表

EXCEL的多个工作表如何导出单个EXCEL工作表

vbscript 将来自不同工作簿的所有工作表合并到一个工作簿中