"excelobject.Workbooks.Open" suddenly does not work

"excelobject.Workbooks.Open" suddenly does not work

bwangNYAKX
Contributor Contributor
3,629 Views
15 Replies
Message 1 of 16

"excelobject.Workbooks.Open" suddenly does not work

bwangNYAKX
Contributor
Contributor

Guys: 

 

I developed some VBA codes that communicate with some excel sheets, and grab the necessary data. These codes has been working great for the past months but all in a sudden, all the lines involving excelobject.workbooks.open fail. The codes will give me an error when running the workbooks.open method: Run-time error: '-2147319765(8002802b)' Automation error Element not found.  There is nothing wrong with the path of the excel workbook. I can run the same code without problems by excel vba editor, but when I run it in Inventor or AutoCAD, it fails.

 

My co-worker had this issue yesterday and he reported to me but I didn't have this issue yesterday. However, after restarting my computer, which means my computer will have some routine updates by the company, the code doesn't work anymore.

 

I would really appreciate it if anyone can help me debug this.. Thank you all in advance. 

 

 

 

 

 

 

 

 Dim oexcelApp As Object 
    'Try to connect to a running instance of Excel.
                        On Error Resume Next
                                       Set oexcelApp = GetObject(, "Excel.Application")
                                         oexcelApp.DisplayAlerts = False
                                    If Err Then
                                     Err.Clear
                                           Set oexcelApp = CreateObject("Excel.Application")
                                              oexcelApp.DisplayAlerts = False
                                            If Err Then
                                               MsgBox "Cannot access excel."
                                               Exit Sub
                                            End If
                                       End If
 
    Dim oWb As Workbook
    Set oWb = oexcelApp.Workbooks.Open("W:\Model Library\<FOLDER>\PARTS LIST (WEIGHT).xlsx")
   
                        If Err Then
                            MsgBox "Unable to open the Excel document: Weight Spreadsheet."
                            Exit Sub
                        End If

0 Likes
3,630 Views
15 Replies
Replies (15)
Message 2 of 16

CattabianiI
Collaborator
Collaborator

Would you please try these 2 lines in iLogic and let me know if you get an error?

' Sheet1 or the name of the sheet you want to open
GoExcel
.Open("W:\Model Library\<FOLDER>\PARTS LIST (WEIGHT).xlsx", "Sheet1") MsgBox("DONE")

 

0 Likes
Message 3 of 16

bwangNYAKX
Contributor
Contributor
 

Thanks, man. I got the following error: 

Capture.PNG

 

GoExcel.Open("C:\Users\zwang\Desktop\try6.xlsx", "Sheet1")
GoExcel.CellValue("B1") = "1"
MsgBox("DONE")

 

0 Likes
Message 4 of 16

kyled
Enthusiast
Enthusiast

Following. Our company is getting the same error for same type of code. seems to be linked to excel updates outside of inventor. we have machines going to down every few days as excel updates. havent narrowed it down yet. we have been using this code for years as is like above and its just crapping out now.

0 Likes
Message 5 of 16

Carson_Gus
Contributor
Contributor

Can confirm, this is affecting our firm just recently as well. Same runtime error, same workbooks.open call.

 

This is not happening to every user in our group. There are a few users who have reported no issues with programs that use this function. The only noticeable difference of interest with these users are that those with broken VBA code are running the Current Channel release schedule of Office 365, while those with working code are on the Semi-Annual Enterprise Channel.

 

See here for a breakdown of these channels. I'm not sure if this is related to the issue at hand, but it is basically the only correlation I've been able to find.

Carson Gustafson
0 Likes
Message 6 of 16

CattabianiI
Collaborator
Collaborator

That is what I was hoping for, to pick up some people with the same error to push Autodesk to take actions. 
This is the issue reported in 2018 but our company and our customers are experiencing this problem a lot recently.

I don't think the suggested solutions are acceptable in every instance:

  • Re-install or repair install Microsoft Office
  • Re-install the operating system on the affected machine


Could Autodesk ( @johnsonshiue , @JaneFan ) dig a little deeper into this issue? 

0 Likes
Message 7 of 16

bwangNYAKX
Contributor
Contributor

I talked to my IT department and reinstalled my Microsoft Office Suite. Problem solved for now.

0 Likes
Message 8 of 16

Anonymous
Not applicable

I had the problem too. Did an online repair of the Office 365 suite, fixed the problem as well.

0 Likes
Message 9 of 16

bwangNYAKX
Contributor
Contributor

A repair of Microsoft Office solved my problem, but only for two weeks.... The problem showed up again after a restarting of my computer recently......  Has the problem occurred again on your computer after your Microsoft Office repair?

0 Likes
Message 10 of 16

kyled
Enthusiast
Enthusiast

the problem has been coming back for us as well but another reinstall of office fixed again. we are going to have to look into it further but for now its keeping IT on the phone just in case

0 Likes
Message 11 of 16

Anonymous
Not applicable

The problem is back again two weeks later when I opened my inventor VBA. My computer has not restarted or has been shutdown in the past two weeks. A quick Microsoft Office repair fixed it.

0 Likes
Message 12 of 16

JelteDeJong
Mentor
Mentor

i did get the exact same error. on the machine of a collage. And would like to follow this thread.

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 13 of 16

johnsonshiue
Community Manager
Community Manager

Hi Folks,

 

I was not aware of the issue. Based on your description, it seems that the failure can be reproduced with Inventor and AutoCAD. It sounds like there is a general communication between Windows apps. The first thing I would do is to install all critical Windows updates. We have been impacted by some regressions in Windows updates. Microsoft usually fixes it in a timely matter, particular when affecting many users.

Another possibility is due to change in security policy. Though I don’t have a solid proof, I notice that the newer Windows versions have tighter user security control. It does not seem to like App A to launch App B in certain cases. You may want to make sure you run Inventor and AutoCAD “as admin.”

Lastly, it is possible the Microsoft Office was not installed or registered properly. You may need to uninstall Office and reinstall it. Also, register Inventor using the following command.

 

Go to CMD. Copy and paste the exact statement (replace 20xx with your current version).

“C:\Program Files\Autodesk\Inventor 20xx\Bin\Inventor.exe” /install

 

In the meantime, I will work with our project team and see if this is a known issue.

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 14 of 16

hendrik.pleines
Explorer
Explorer

We are facing the exact same errors during our Autodesk Rollout and need to reinstall Office for several users. As this is not an acceptable solution we just stopped the further Rollout of any Autodesk products. 

0 Likes
Message 15 of 16

kyled
Enthusiast
Enthusiast

has anybody come up with a permanent fix on this one?

0 Likes
Message 16 of 16

kyled
Enthusiast
Enthusiast

not sure if this will help in anyone else's situations, but I was able to get around the error by adding "on error resume next" and it just keeps on keeping on. 

 
 

you-gotta-keep-on-keepin-on.jpg