0

背景:大约。300 个 Excel 调查(包含多张工作表)应集中在 1 个 Excel 中。宏已准备就绪。目标:虽然宏已经准备好并且能够从调查 Excel 中复制所需的数据,但我无法一次复制所有 300 个调查(我必须逐个完成所有调查)

问题:是否可以要求宏从特定网络路径复制目标,从而复制所有 300 个 excel 工作簿?

宏脚本:

Function bIsBookOpen(ByRef szBookName As String) As Boolean
    On Error Resume Next
    bIsBookOpen = Not (Application.Workbooks(szBookName) Is Nothing)
End Function

Sub Start()
currwb = ActiveWorkbook.Name

If bIsBookOpen("PERSONAL.XLSB") Then
    Windows("PERSONAL.XLSB").Visible = True
    ActiveWindow.Close
End If

If Workbooks.Count > 1 Then
MsgBox " To many files open...  " & Workbooks(1).Name
Else
Application.Dialogs(xlDialogOpen).Show
Response = MsgBox("Weiter mit 'IT-Personal'?", vbYesNo)
If Response = vbYes Then
Windows(currwb).Activate
Call CopyForm
End If

End If

End Sub
4

1 回答 1

1

要遍历文件夹中的文件,

Sub LoopThroughFiles()
    Dim path As String
    Dim filename As String
    Dim wb As Workbook
    path = ""  'your folder path here
    filename = Dir(path & "*.xls")

    While (filename <> "")
        Set wb = Workbooks.Open(path & filename)
        'Your code goes here
        wb.Close
        filename = Dir
    Wend
End Sub
于 2013-10-08T08:51:01.533 回答