title: Python script called in VBA/Excel
body: <p>I have a problem with my VBA code to call a Python Script, which downloads a CSV from a web page. In Visual Studio Code, I can execute it and the date of my result file changes. But, if I try to call this script in VBA, open <code>python.exe</code>, do something (I don't know), and close it, and my date of my csv file doesn't upload.</p>
  <p>My VBA code is:</p>
  <pre class="lang-vb prettyprint-override"><code>Sub Download_CSV_Python()
  
  'Procedure to run a Python Script in a VBA Procedure using the shell
   
      'Declaration
      Dim objShell As Object 'For the Shell
      Dim Pythonexe, PythonScript As String
       
      'Create the Shell Object
      Set objShell = VBA.CreateObject(&quot;WScript.Shell&quot;)
      
      'path of the python.exe
      Pythonexe = &quot;&quot;&quot;C:\Users\sergi\AppData\Local\Programs\Python\Python310\python.exe&quot;&quot;&quot;
      
      'path of your Python script
      PythonScript = &quot;C:\Users\sergi\Desktop\Python\CSVChrome4.py&quot;
       
      'Run your Python script
      objShell.Run Pythonexe &amp; PythonScript
   
      'free variables for memory
       Set objShell = Nothing
        
  End Sub
  </code></pre>
  <pre><code>from pytrends.request import TrendReq
  import pandas as pd
  import time
  startTime = time.time()
  pytrend = TrendReq(hl='en-GB', tz=360)
  
  colnames = [&quot;keywords&quot;]
  df = pd.read_csv(&quot;keyword_list.csv&quot;, names=colnames)
  df2 = df[&quot;keywords&quot;].values.tolist()
  df2.remove(&quot;Keywords&quot;)
  
  dataset = []
  
  for x in range(0,len(df2)):
       keywords = [df2[x]]
       pytrend.build_payload(
       kw_list=keywords,
       cat=0,
       timeframe='today 12-m',
       geo='')
       data = pytrend.interest_over_time()
       if not data.empty:
            data = data.drop(labels=['isPartial'],axis='columns')
            dataset.append(data)
  
  result = pd.concat(dataset, axis=1)
  result.to_csv('search_trends.csv')
  
  executionTime = (time.time() - startTime)
  print('Execution time in sec.: ' + str(executionTime))
  enter code here
  </code></pre>