I'd like to redo all
my Visual Basic Projects in Python ... I would have started down the
Python path from the get-go but was in too much of rush. Now that I
have a moment, I thought I'd get the help I need.
I know how to
connect to Excel:
win32com.client.Dispatch("Excel.Application").
How do I connect to
a VisualBasic project?
I need more help
than that though.
I can run a *.py
script from a Visual Basic application but I'm not quite sure how to keep
running so I don't lose the objects and variables I populate the first time I
run the program ... I need to run additional programs using that
data.
If I can do this
I'll be golden:
Imagine an Excel
Macro Start that does the following:
Sub
Start():
Set form = MyUserForm
load form
form.show vbmodeless
<run the Python module described below>
end
sub
Imagine userform
"MyUserForm" with two CommandButtons ... "init" and "getdouble" and a
TextBox "result"
My VisualBasic
UserFormModule would have the following (pseudo)code:
sub
init_click()
initval=inputbox("enter the initialization value")
<run the function init(initval) in the aforementioned Python
module>
end
sub
double_click()
<run the function
doubleval() in the aforementioned Python module>
end
A python module
that would work for me would be:
import
win32com.client
XLApp=win32com.client.Dispatch( "Excel.Application")
VBProj
=win32com.client. Dispatch( ?)
class
XLProj:
def __init(self)__:
self.val=None
def
init(initval):
MyProj.val=initval
def
doubleval():
VPProj.MyUserForm.Controls("result").Value=MyProj.val*2
MyProj=XLProj()
This information contained or attached to this e-mail may be subject to the Export Administration Regulations (EAR) or the International Traffic in Arms Regulations (ITAR) and may require an approved export license prior to its export. An export can include a release or disclosure to a foreign national inside or outside the United States. Include this notice with any reproduced portion of this information.
_______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32