Call VBScript from VBA, pass variable, return result to macro?

E

Ed

Karl: I went back and re-read ~everything~ again, caught the bit about
_removing_ the arguments, and even added the Sleep API as originally
recommended.

Everything runs without errors. Sleep is at 5000, so I get a good
glimpse of the command window. It's totally blank.

Unless you've got a brilliant flash of insight into my stumblings, I'm
going to chalk it up as not knowing enough about what I want to do.
With a long weekend coming up, I'll have to be re-trained next week
anyway! So I'll read some more and play some more, and maybe give this
another round on the NG in a week or three.

Thanks to all for all the help and support.
Ed
 
E

Ed

OMG!! I think I did something right! I opened the Command window in
Accessories, had to CD to the right directory (it failed somehow when I
tried to just type in the whole line), then did "cscript MacroTest.vbs
ABC 2".

Sure enough, I get
ABC
2
in the Command window!

So at least (and at last!) ~something~ is working, Karl, thanks to the
great patience of you and the others here! Where should I go for the
next baby step?
Ed
 
K

Karl E. Peterson

Ed said:
OMG!! I think I did something right! I opened the Command window in
Accessories, had to CD to the right directory (it failed somehow when
I tried to just type in the whole line), then did "cscript
MacroTest.vbs ABC 2".

Sure enough, I get
ABC
2
in the Command window!

So at least (and at last!) ~something~ is working, Karl,
:)

thanks to the
great patience of you and the others here! Where should I go for the
next baby step?

Well, a messagebox might be a little more noticable than an echo?
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")WshShell.popup This, , "Args(0)"
WshShell.popup That, , "Args(1)"
Maybe edit that, and (after making sure it works from the command prompt!)
trying it from VBA.
 
J

Jonathan West

Hi Ed,

While all of this is fascinating stuff, you do seem to be trying to use a
hammer to put a screw in the wall.

If you want to use regexp, you can do so even more easily from VBA than you
can from VBScript. John Nurick already posted a web page describing how to
do this

http://www.j.nurick.dial.pipex.com/Code/index.htm

If you want to pass parameters to a subroutine and return a value to the
calling routine, this is also much easier in VBA. I pointed out a simple
tutorial on this here

http://www.word.mvps.org/FAQs/MacrosVBA/ProcArguments.htm

There are code examples of both Subs and Functions in the VBA Help. Just
position the cursor on the word "Sub" or "Function" in the VBA editor and
press F1.

Before you go any further down th VBScript route, I do urge you to take a
look at these pages.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
K

Karl E. Peterson

Jonathan said:
While all of this is fascinating stuff, you do seem to be trying to
use a hammer to put a screw in the wall.

That'd be relatively easy, compared to using a screwdriver to pound a nail!

(My sense is he's closer to the latter than the former. said:
Before you go any further down th VBScript route, I do urge you to
take a look at these pages.

Yep, going the route I was helping with would need some serious
justification, which could even include raging boredom I suppose. <g>
 
E

Ed

Sorry, guys. I couldn't find the Hammer or Screwdriver Functions in
VBScript. Guess I nees to go back and re-read about the tollbox?

Seriously, thanks for all our help. You're right - I am beginning to
see that I was doing things the _very_ hard way. Unfortunately, I
didn't know enough at first to know that. I appreciate all the
comments and pointers. I will come back when I can ask more
intelligent questions.

Ed
 
J

Jean-Guy Marcil

Ed was telling us:
Ed nous racontait que :
Sorry, guys. I couldn't find the Hammer or Screwdriver Functions in
VBScript. Guess I nees to go back and re-read about the tollbox?

Seriously, thanks for all our help. You're right - I am beginning to
see that I was doing things the _very_ hard way. Unfortunately, I
didn't know enough at first to know that. I appreciate all the
comments and pointers. I will come back when I can ask more
intelligent questions.

There are no "unintelligent" questions when we are sincere.
We all have been there at some point or another, and still are depending on
the topic.

So don't worry, keep at it, come back with questions anytime you need it!

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
K

Karl E. Peterson

Ed said:
Seriously, thanks for all our help. You're right - I am beginning to
see that I was doing things the _very_ hard way.

That's often the fastest way to learn the most. said:
Unfortunately, I didn't know enough at first to know that.
See?

I appreciate all the comments and pointers.
I will come back when I can ask more intelligent questions.

Good luck...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top