Click to See Complete Forum and Search --> : Scripting Using VBA6.DLL (WSH not required!)


Chris Eastwood
February 25th, 2000, 05:33 AM
I've just found some very interesting code on the net - it allows you to call a routine in vba6.dll and pass a line of visual basic code for it to execute (without the need of the WSH) :


'------------------------------------------
' (c) 1999 Trigeminal Software, Inc. All Rights Reserved
'------------------------------------------
option Compare Text
option Explicit
'
Declare Function EbExecuteLine Lib "vba6.dll" _
(byval pStringToExec as Long, byval Foo1 as Long, _
byval Foo2 as Long, byval fCheckOnly as Long) as Long
'
' for VB5 IDE
'Declare Function EbExecuteLine Lib "vba5.dll" _
' (byval pStringToExec as Long, byval Foo1 as Long, _
' byval Foo2 as Long, byval fCheckOnly as Long) as Long
'
' for Access 97/VBE.dll clients like Word 97 and Excel 97
'Declare Function EbExecuteLine Lib "vba332.dll" _
' (byval pStringToExec as Long, byval Foo1 as Long, _
' byval Foo2 as Long, byval fCheckOnly as Long) as Long
'
public Function FExecuteCode(stCode as string, _
optional fCheckOnly as Boolean) as Boolean

FExecuteCode = EbExecuteLine(StrPtr(stCode), 0&, 0&, fCheckOnly) = 0
End Function
'




Sample Usage :

FExecuteCode "MsgBox ""this is a test"",,""Chris!"""




I was wondering if anyone out there knew about any other interfaces into vba6.dll ?


Chris Eastwood

CodeGuru - the website for developers
http://codeguru.developer.com/vb