Method 'Run' of object 'IWshShell3' Failed (80070002)

snuffnchess

Board Regular
Joined
May 15, 2015
Messages
71
Office Version
  1. 365
Platform
  1. Windows
I have been running the below code in projects on my computer and various others with no issue... but I have a coworker that is getting a Run-Time Error '-2147024894 (80070002)' / Method 'Run' of object 'IWshShell3' Failed message when I try to run the macro on their system

VBA Code:
Private Sub ManageOnedriveSync(ByVal action As Integer)


    Dim shell As Object
    Set shell = VBA.CreateObject("WScript.Shell")
    Dim waitTillComplete As Boolean: waitTillComplete = False
    Dim style As Integer: style = 1
    Dim errorcode As Integer
    Dim path As String


    Dim commandAction As String
    Select Case action
    Case 1
        commandAction = "/shutdown"
    End Select


    path = Chr(34) & "%programfiles%\Microsoft OneDrive\Onedrive.exe" & Chr(34) & " " & commandAction


    errorcode = shell.Run(path, style, waitTillComplete)


End Sub

Sub Test()

ManageOnedriveSync 1

End Sub

I have tried using the direct path to the onedrive.exe file as well, and that did not alter the error message. Is there something else that i should be trying?

(code was originally copied and used over and over and over again on my PC and others without issue from VBA start stop Onedrive Sync client)
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,223,888
Messages
6,175,207
Members
452,618
Latest member
Tam84

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