我有一个功能,可以查找打开的工作簿,并将它们拉入主工作簿。当我导入用office的现代版本创建的工作簿时,它工作得很好,但它似乎检测不到在兼容模式下打开的工作簿。对于有问题的工作簿,只有剩下的24个字符是常量。
由于各种各样的原因,我已经在其他帖子中介绍过,下载有问题的工作簿不是一种选择。
下面是函数。
Public Sub FindReport()
Debug.Print "Finding Report"
On Error GoTo Failed
Dim rName() As String
Dim wb As Workbook
Dim tWb As Workbook
rName(0) = "Case Detail"
rName(1) = "Disability_Claim_Status_"
'rName(2) = "placeholder"
For Each wb In Workbooks
'This line gives no output when I have the function try to find a workbook
'that has opened in compatibility mode
Debug.Print wb.Name
If Left(wb.Name, 11) = rName(0) Then
Set tWb = wb
ImportReport tWb
tWb.Close
CaseFAS
Exit For
End If
If Left(wb.Name, 24) = rName(1) Then
Set tWb = wb
ImportReport tWb
tWb.Close
'CaseFAS
Exit For
End If
'If Left(wb.Name, 11) = rName(2) Then
' Set tWb = wb
' ImportReport tWb
' tWb.Close
' 'CaseFAS
' Exit For
'End If
Next wb
Failed:
End Sub编辑以澄清:
我有一个从网站打开的特定工作表的代码的另一个版本,现在我需要扩展它来处理另一个工作表,我相应地修改了声明,并搞砸了数组的声明。
发布于 2021-05-21 16:00:15
https://stackoverflow.com/questions/67632408
复制相似问题