I have the following python script that deletes the blank line that appears when exporting an excel sheet as .txt and moves it to a different path
fd=open("D:\\Arturo\\Documentos\\8 Semestre\\Tutoreo\\Exportación como TXT VBA\\Trigger.txt","r")
d=fd.read()
fd.close()
m=d.split("\n")
s="\n".join(m[:-1])
fd=open("D:\\Arturo\\Documentos\\8 Semestre\\Tutoreo\\Exportación como TXT VBA\\Trigger.txt","w+")
for i in range(len(s)):
fd.write(s[i])
fd.close()
import shutil
original = "D:\\Arturo\\Documentos\\8 Semestre\\Tutoreo\\Exportación como TXT VBA\\Trigger.txt"
target = "C:\\Users\\artur\\Desktop\\Trigger\\Trigger.txt"
shutil.copyfile(original, target)
and this is how I call the script in vba
Sub eliminar_linea_py()
Dim objShell As Object
Dim PythonExe, PythonScript As String
Set objShell = VBA.CreateObject("Wscript.Shell")
PythonExe = """C:\Users\artur\AppData\Local\Programs\Python\Python310\python.exe"""
PythonScript = "C:\Users\artur\Desktop\py4e\remove_last_line.py"
objShell.Run PythonExe & PythonScript
End Sub
I'm working in the company computer and don't have admin permissions, when I try to run python script with VBA it doesn't work, how ever if I run the python script through command window it works perfectly, any idea of why this is happening and how could it be solved.
I have tried it in my personal laptop and vba its able to run the script without any issues.
Sorry for the long text, thank you for you time.