Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
syntax
What is the syntax for transfering the value of a varible
in VB6 into VBA, so I can use it in Excel. strQtNum has been DIM'd in VBA. We can Import Databases, but variables I do not know. Thanks. Don |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
syntax
"Don" wrote in message
... What is the syntax for transfering the value of a varible in VB6 into VBA, so I can use it in Excel. strQtNum has been DIM'd in VBA. We can Import Databases, but variables I do not know. Hi Don, Two ways I can think of right off the bat. 1) Have your VB6 DLL or EXE write the value of the variable to a known cell in a worksheet of an open workbook on the Excel side and then have VBA read the value of the variable from that cell. 2) If you have a class within your VB6 DLL or EXE that VBA has a reference to, add a Property procedure to that class that returns the value of the variable. Then have VBA call that property of the class to retrieve the variable's value. If you'd like more detail on how to implement either of these methods, post back with a bit more detail on exactly what the relationship is between Excel and VB6 in your project and I'll be glad to help you out. -- Rob Bovey, MCSE, MCSD, Excel MVP Application Professionals http://www.appspro.com/ * Please post all replies to this newsgroup * * I delete all unsolicited e-mail responses * |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
syntax
Variables in VBA follow the same scope and lifetime restrictions as
variables in VB6. So you couldn't create a variable in Excel unless you use the VBA extensibility library and declared it, then wrote code to initialize it and executed the code. Perhaps there is a workaround if you could be more specific about what you want to do. Are you trying to run a macro and to pass it a variable value. in a VBA General Module Public gMyVar as Long Public Sub SetMyVar(myVal) gMyVar = myVal End Sub Public Function MyVar() Application.Volatile myVar = gMyVar End Sub in VB6 someVar = 21 xlApp.Run "MyWorkbook.xls!SetMyVar", someVar A worksheet could use a formula =Sum(A1:B9,MyVar()) -- Regards, Tom Ogilvy Don wrote in message ... What is the syntax for transfering the value of a varible in VB6 into VBA, so I can use it in Excel. strQtNum has been DIM'd in VBA. We can Import Databases, but variables I do not know. Thanks. Don |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
IF, THEN SYNTAX | Excel Worksheet Functions | |||
VB Syntax | Excel Discussion (Misc queries) | |||
Syntax HELP | Excel Discussion (Misc queries) | |||
VBA syntax | Excel Discussion (Misc queries) | |||
If then syntax | Excel Worksheet Functions |