Python code does not run after executing. The code has to read the data frames from the Excel where I run VBA code to execute the python code. Im not sure this could be a reason since I have another totally different excel where I do exactly same running VBA code in excel file to run a python code, which reads the data in this excel file. I get the finished msgbox in less then a second but if I run a code in Pycharm it takes 2 min to finish.
Option Explicit
Sub RunPythonScript()
'Declare Variables
Dim objShell As Object
Dim PythonExe, PythonScript 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\Wholesale - Documents\Report\VL.py"
'Run the Python Script
objShell.Run PythonExe & PythonScript
MsgBox "Finished"
End Sub
Path in python script
import pandas as pd
import numpy as np
import os
# Get the user
username = os.getlogin()
# search for directory
directory = r'C:/Users/' + username + '/Wholesale - Documents/Report/'