"Waiting To Complete An OLE action" locking up Excel during attempt to open files from a directory

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I hope someone is able to help me correct a problem with my VBA code.

Rich (BB code):
                ...
                ElseIf mi5 = "GE" Then
                    StrFile = Dir(path_name & "*-GE.docx")
                    Do While Len(StrFile) > 0
                        Debug.Print StrFile
                        Set WordApp = CreateObject("word.Application")
                        WordApp.documents.Open path_name & StrFile
                        WordApp.Visible = True
                        Set WordApp = Nothing
                        StrFile = Dir
                    Loop
                    WordApp.Activate
                    Exit Sub
                Else
                    ....
                End if

This is what I wished this code would do ...
When mi5 = "GE", then open all the Word documents in directory path_name that end with "-GE.docx". For my testing, there are 2 of 13 files that end in "-GE.docx".

What is happening is that my Excel project locks up with the code waiting to complete complete an OLE action. ("Microsoft Excel is waiting for another application to complete an OLE action."). The only way I can recover is to end a task in task manager called "File In Use". Doing so returns me to Excel with an error "Command Failed" with the line highlighted in red.

I'm not all that certain I know how this code works, so I assume I have some things missing and/or out of order. I hope someone is able to help me clean up my code to produce the desired results I seek ... the two reports printed.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
I do not have the same problem if it is just one file meeting the criteria. So clearly, I am going about opening multiple files from the directory wrong.
 
Upvote 0
An answer to another post of mine helped solve this puzzle. I have found an alternate way of doing things that seems to be doing the trick.
 
Upvote 0

Forum statistics

Threads
1,215,133
Messages
6,123,231
Members
449,091
Latest member
jeremy_bp001

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top