Changing working directory from Excel vba shell

前端 未结 4 1736
广开言路
广开言路 2020-12-11 19:43

For work, I\'m trying to run a Python script from an Excel VBA macro.

The macro is as follows -

Sub Plot()

Shell \"C:\\Users\\maheshda\\AppData\\Lo         


        
4条回答
  •  渐次进展
    2020-12-11 19:59

    FCastro, why did you bother with that StrComp line? And, for that matter, why bother with the Strings object?

    I suppose if the drive were external and hadn't been accessed yet it might take a moment, but as long as the path is not expected to be a USB/CD/DVD/etc..., then:

    Public Sub Change_Current_Directory(NewDirectoryPath as string)
        ChDrive Left(NewDirectoryPath,1)
        ChDir NewDirectoryPath
    End Function
    

提交回复
热议问题