我有以下代码,它打开某个WB,从中获取一些信息然后关闭它。问题是,有时WB无法正确关闭。有时,即使用户无法看到WB已打开,Excel仍在运行它,因为如果其他人试图打开它(WB位于共享文件夹中),Excel将不会让他,因为它说其他人已经开通了WB。
Dim iStatus As Long
Err.Clear
On Error Resume Next
Set wb2 = Workbooks("Base de Datos Cotizaciones Shared.xlsb")
iStatus = Err
On Error GoTo 0
If iStatus Then
Workbooks.Open Filename:="\\3kusmiafs02\CAPACITY\Cotizaciones\Base de Datos Cotizaciones Shared.xlsb"
Else
wb2.Activate
End If
On Error GoTo errHandler:
Worksheets("Data").Activate
maxnum = CLng(Application.WorksheetFunction.Max(Range("A:A")))
quote_num = maxnum + 1
ActiveSheet.Cells(ActiveSheet.Rows.Count, "A").End(xlUp).Offset(1, 0) = quote_num
Range("A1").Select
Selection.End(xlDown).Select
Dim input_range As Range
Set input_range = Selection.Offset(0, 1)
wb3.Activate
Worksheets("UI VENTAS").Activate
Range("Quote_num") = quote_num
Application.Goto Reference:="Dimstable"
Selection.Copy
Workbooks("Base de Datos Cotizaciones Shared.xlsb").Activate
Worksheets("Dims").Activate
Range("table_start2").Select
Selection.End(xlDown).Select
Selection.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
For i = 1 To 17
input_range.Offset(0, i - 1).Value = data_values(i - 1)
Next i
input_range.Offset(0, 32).Value = data_values(17)
Workbooks("Base de Datos Cotizaciones Shared.xlsb").Save
Workbooks("Base de Datos Cotizaciones Shared.xlsb").Close
有没有办法解决这个问题?