Hello everyone !
So I'm working on a macro that has to retrieve the path of my PnP device in order to run a .bat file. To call the bat file I use the Shell() function. Both of the doc (containing the macro) and the .bat are in the said PnP device.
Before sending my doc and the bat to the my USB key, I tried it on my PC and everything runned smoothly. Since everything is on the key I can still retrieve the path (as shown in the code down bellow) but the bat file doesn't run because Shell() doesn't find the script.
So hum... yeah... how can I get a valid path to the .bat for Shell() to run ?
Private Sub Document_Open()
' Declaring mandatory variables
Dim filePath As String
Dim PID As Double
' Getting the path to the .bat
' filePath = ActiveDocument.Path & "\CP.bat"
filePath = ".\USB_Campaign\CP.bat"
MsgBox filePath
PID = Shell(filePath, vbNormalFocus)
End Sub
As you can see I tried different methods to retrieve the path in hope it would be accepted by Shell() (Spoiler : it was no use :p).
I hope my explanation was clear enough.
Looking forward to your answer !
PS : it's my first post on this forum, so tell me if I should post that somewhere else. Plus : I didn't find any thread discussing that particular question, but if I'm wrong I'd be more than happy to check it out
Bookmarks