excel - Run Python script via VBA and give name and path of active workbook? -


edit: same question rewrote it, more legible.

i tried post: how call python script on excel vba?

and post: run , execute python script vba

and post: how can call python program vba?

but none of answers works me , have no idea i'm doing wrong. problem 1: want run pythonscript vba excel. excel file doesn't have home place (can on desktop). code (want to) use:

 dim ret_val  ret_val = shell("c:\python27\python.exe \\10.31.13.22\shareddocs\3 - technical\13 - reports & templates\13 - description\descriptiontodatabase.py") 

the pythonfile has same path on server. cannot see wat wrong here? black python screen.

in python file call workbook , correct sheet:

book = xlrd.open_workbook("//10.31.13.22/shareddocs/3 - technical/1 - projects/0 - internal/rpa 138 - engineering software/testchipdescription/upload database/testchipdescription-template-10-11.xltm") sheet = book.sheet_by_name("database") 

at moment excel workbook path hardcoded in python. bring me problem 2: can pass name , path of excel workbook somehow pythonscript?

edit:

i tried shell()code in command prompt. same in vba:

"c:\python27\python.exe \\10.31.13.22\shareddocs\3 - technical\13 - reports & templates\13 - description\descriptiontodatabase.py" 

it doesn't work. 'the system cannot find path specified'.

i tried one:

c:\python27\python.exe "\\10.31.13.22\shareddocs\3 - technical\13 - reports & templates\13 - description\descriptiontodatabase.py" 

and works! cmd needs "" handle spaces in path. can't add them in vba because cannot place 2 "" otherwise errors.

i wondering if possible give name , path of active excel workbook python script call active workbook?

yes. you can pass argument(s) shell function vba, , need modify python script accept argument(s) , it/them.

python read stdin arguments

python read command line arguments or stdin


Comments

Popular posts from this blog

xcode - CocoaPod Storyboard error: -

c# - AutoMapper - What's difference between Condition and PreCondition -