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

snuffnchess

Board Regular
Joined
May 15, 2015
Messages
68
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

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,215,491
Messages
6,125,101
Members
449,205
Latest member
ralemanygarcia

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