I want simple and easy integration of python and vba.
People, reading this may kill me if they meet me in person after reading this but I am using django development server for this purpose.
Is there any simple and better way.
Just for example:
I want to export comma separated string as excel file using python moduel openpyxl.
This is django app url.py
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'identifier(.*)$', views.demo, name='index')
]
This is django app views.py
from django.http import HttpResponse
from openpyxl import Workbook
def demo(request, data):
(identifier, numbers, filepath) = data.split(';;;')
wb = Workbook()
ws_sent = wb.active
for number in numbers.split(','):
ws_sent.append((number.strip(),))
wb.save(filepath + identifier + '.xlsx')
return HttpResponse(identifier + " : Completed")
vba:
Sub demohttp()
Set httpobject = CreateObject("MSXML2.XMLHTTP")
url = "http://localhost:8000/appname/identifier;;;1,2,3,4,5,6,7,8,9;;;C:/ActiveDocument.Path"
httpobject.Open "GET", url, False
httpobject.send
msgbox httpobject.responseText
End Sub
This is blazing fast compared to: calling python from vba shell functions
This is amazingly simple compared to: automating excel from word vba. Excel is just an example. I have so many python scripts I wanted to convert to django apps.
Questions 1) is there any downfall? I have checked it for my maximum number count up to 1200 unique numbers.
2) is there any better way? I tried to learn server side com but looks like mess.