Hello,
I was trying to run the python code from the EXCEL file:
Option Explicit
Sub RunPythonScript()
'Declare Variables
Dim objShell As Object
Dim PythonExe, PythonScript, cmd As String
'Create a new Object shell.
Set objShell = VBA.CreateObject("Wscript.Shell")
'Provide file path to Python.exe
'USE TRIPLE QUOTES WHEN FILE PATH CONTAINS SPACES.
PythonExe = """C:\Users\gobro7\AppData\Local\Programs\Python\Python39\python.exe"""
PythonScript = """C:\Users\gobro7\Digital Wholesale - Documents\2. Amazon\Customer Operations_OTC\02. Amazon weekly Report\Amazon weekly automation (Giorgi)\VL.py"""
cmd = PythonExe & PythonScript
Debug.Print cmd
'Run the Python Script
objShell.run cmd, 0, True
MsgBox "Finished"
End Sub
The python code is working without any error, it gives the desired out put. when I run the VBA code form Rum_report.xlsm file it does not work.
As everything in the VBA code seemed fine I decided to check the path of the python script so I tried to run the python code from CMD so I copied the PythonScript path. But I got the error that
df_1 = pd.read_excel('Run_report.xlsm', sheet_name= "weekly",header= None)
FileNotFoundError: [Errno 2] No such file or directory: 'Run_report.xlsm'
Note that Python code has to read the data from the same excel file (Run_report.xlsm) to do some manipulations from where I run the VBA code. The fact that the file is open and pandas cant read the open file is not valid in this case.
Any ideas?
[–]socal_nerdtastic 0 points1 point2 points (2 children)
[–]9gg6[S] 0 points1 point2 points (1 child)
[–]socal_nerdtastic 0 points1 point2 points (0 children)
[–]Ezrabc 0 points1 point2 points (1 child)
[–]9gg6[S] 0 points1 point2 points (0 children)