How to make this Python code run with VBA

It works perfectly when I execute it from my notebook, but it does nothing when I execute it from VBA using the code above. Only returning the msgbox, but not creating the excel file I need. How can I archive what I need by making VBA and my python script work together ? Is it possible to execute what this python code do with only VBA ? how ?

Run Python scripts directly from Excel using VBA . This guide shows you how to set it up with simple code examples and practical tips.
How can I call a Python script on Excel VBA

I am trying to call a Python script on VBA , and I am new to this. I tried converting the main script to an EXE file using py2exe and then calling it from VBA (shell), but the main script calls other scripts , and therefore it becomes complicated and I messed it up (my EXE file is not functional).
Possible duplicate of Calling python script from excel / vba , How to call python script on excel vba ?, Is there a way to call a Python code in Excel - VBA ?, Run and execute a python script from VBA , etc.

Run python script directly from excel file
Overview In this tutorial, I'll show you how to run python script directly from excel file using excel VBA I am assuming you already have python installed on your system and comfortable with installing python packages Prepare your environment and python script For this tutorial I am going to use very simple python script to calculate area, sample code is given below Name of this python ...
Create a subroutine in VBA that runs any python script First, we declare the variable needed for the subroutineto run the script , namely the object shell, folder paths and the command used by the ...
How to call python script on excel vba
Using the Shell function: Open Excel and press Alt + F11 to open the VBA editor. Insert a new module by right-clicking on any item in the Project Explorer and selecting Insert > Module. In the module, write the following VBA code: Sub RunPythonScript () Dim objShell As Object Set objShell = VBA .CreateObject ("WScript.Shell") ' Specify the path to your Python executable and script Dim ...
However, if it is possible to run a script in a different programming language (e.g., Python ) within Excel VBA , it can be even more helpful in automating our routine tasks. In this post, I will share my experience of using Excel VBA and Python to perform a simple task - time series resampling of solar irradiance data.

The Complete Guide to Running Python Scripts from Excel VBA
To run Python scripts from Excel VBA , the Shell function is primarily used. This method provides a straightforward means of launching external programs from VBA .








Call Python with "RunPython" ¶ In the VBA Editor (Alt-F11), write the code below into a VBA module. xlwings quickstart automatically adds a new module with a sample call. If you rather want to start from scratch, you can add a new module via Insert > Module.