Hello,
I'm going crazy trying to figure this out. I have, for security reasons, placed an embedded excel object (as an icon) in a very hidden sheet. Various code pulls up the object, extracts or adds data, and closes it with screen updates off. The code below works perfectly in Excel 2013, but in 2010 I am getting an error message: '-2147417848 *80010108)': Method 'Close' of object'_Workbook' failed.
After several hours of trying different methods and researching, I've got nothing. In debugging, the highlighted code is Workbook.Close. Regardless of what I do, Excel 2010 freezes up and I have to end the program. Please help!
I'm going crazy trying to figure this out. I have, for security reasons, placed an embedded excel object (as an icon) in a very hidden sheet. Various code pulls up the object, extracts or adds data, and closes it with screen updates off. The code below works perfectly in Excel 2013, but in 2010 I am getting an error message: '-2147417848 *80010108)': Method 'Close' of object'_Workbook' failed.
After several hours of trying different methods and researching, I've got nothing. In debugging, the highlighted code is Workbook.Close. Regardless of what I do, Excel 2010 freezes up and I have to end the program. Please help!
Code:
Sub testing()
Dim wb As Workbook: Set wb = ThisWorkbook
Dim wbname As String: wbname = Replace(wb.Name, ".xlsm", "")
Dim oEmbFile As Object
Set oEmbFile = ThisWorkbook.Sheets("Login").OLEObjects("ok")
oEmbFile.Verb Verb:=xlPrimary
For Each Workbook In Workbooks
If Workbook.Name = ("Worksheet in " & wbname) Then Workbook.Close
Next
Set oEmbFile = Nothing
End Sub
Last edited: