Excel工作簿在模块中包含以下VBA宏,并在多个单元格中调用它以生成值。
当共享工作簿时(Review - > Share Workbook),打开工作簿时会显示一个带有“Automation error”的消息框,除了从任务中删除Excel进程外,用户无法执行任何操作管理器。
Excel 2013会发生这种情况,无论工作簿是否已被其他人打开过。
我唯一想到的解决方案是从工作簿中删除VBA代码并存储在外部XLAM加载项中,如建议的here。出于几个原因,我不想这样做。顺便说一句,我已经尝试过这个解决方案,并且每次打开工作簿时都会显示一条消息,说明无法更新某些链接。
您知道是否有办法避免此“自动化错误”消息?也许它与宏名称,VBA项目中的一些引用或其他任何内容有关?
Public Function OutFileName(OutType As String, OutNum As String) As String
' This function generates a filename from a file type and number
Dim TempStr As String
Dim i As Integer
TempStr = LCase(Left(OutType, 1)) & OutNum
' If number begins with &, we directly go to the end of the macro
If Left(OutNum, 1) = "&" Then
GoTo EndOfMacro
End If
' If it ends with a point and a digit, add a zero before the digit
If Mid(TempStr, Len(TempStr) - 1, 1) = "." Or Mid(TempStr, Len(TempStr) - 1, 1) = "-" Then
TempStr = Left(TempStr, Len(TempStr) - 1) & "0" & Right(TempStr, 1)
End If
' Replace "." and "-" by underscore after "-"
For i = Len(TempStr) To 1 Step -1
If Mid(TempStr, i, 1) = "." Then
TempStr = Left(TempStr, i - 1) & "_" & Right(TempStr, Len(TempStr) - i)
End If
If Mid(TempStr, i, 1) = "-" Then
TempStr = Left(TempStr, i - 1) & "_" & Right(TempStr, Len(TempStr) - i)
Exit For
End If
Next
' Delete other points and "-"
TempStr = Replace(TempStr, ".", "")
TempStr = Replace(TempStr, "-", "")
EndOfMacro:
OutFileName = TempStr
End Function