By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,516 Members | 1,137 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,516 IT Pros & Developers. It's quick & easy.

How to Dim

P: n/a
I want to run a .reg patch from VBA.

I am using:

Dim RunReg
RunReg = Shell("regedit.exe /s I:\MyFolder\SQLfix.reg", 0)

It just doesn't look quite right to me. Should there be something after the
"Dim Runreg"?

dixie
Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a

"dixie" <di***@dogmail.com> wrote in message
news:41******@duster.adelaide.on.net...
I want to run a .reg patch from VBA.

I am using:

Dim RunReg
RunReg = Shell("regedit.exe /s I:\MyFolder\SQLfix.reg", 0)

It just doesn't look quite right to me. Should there be something after
the "Dim Runreg"?

dixie


You can use this:

dim RunReg as integer


Nov 13 '05 #2

P: n/a
dixie wrote:
I want to run a .reg patch from VBA.

I am using:

Dim RunReg
RunReg = Shell("regedit.exe /s I:\MyFolder\SQLfix.reg", 0)

It just doesn't look quite right to me. Should there be something after the
"Dim Runreg"?

dixie


Unless you want the return code from the shell function...

Shell "regedit.exe /s I:\MyFolder\SQLfix.reg", 0

will work, if you want the return code then your Dim is fine as it
defaults to Variant but you can use:

Dim RunReg As Variant

for clarity.


--
This sig left intentionally blank
Nov 13 '05 #3

P: n/a
Thanks Trevor, I do want the return code. So my ordinary Dim will work OK
as it has a default value. There is probably no point in changing it then.

Tah,
dixie

"Trevor Best" <no****@besty.org.uk> wrote in message
news:41**********************@news.zen.co.uk...
dixie wrote:
I want to run a .reg patch from VBA.

I am using:

Dim RunReg
RunReg = Shell("regedit.exe /s I:\MyFolder\SQLfix.reg", 0)

It just doesn't look quite right to me. Should there be something after
the "Dim Runreg"?

dixie


Unless you want the return code from the shell function...

Shell "regedit.exe /s I:\MyFolder\SQLfix.reg", 0

will work, if you want the return code then your Dim is fine as it
defaults to Variant but you can use:

Dim RunReg As Variant

for clarity.


--
This sig left intentionally blank

Nov 13 '05 #4

P: n/a
dixie wrote:
Thanks Trevor, I do want the return code. So my ordinary Dim will work OK
as it has a default value. There is probably no point in changing it then.


When interrogating the return value, you might consider checking if the
variant is empty (IsEmpty() function) unless you have initialised the
variable beforehand.

You could also Dim as Double since Shell returns a variant of sub type
Double. In any case it's better to be explicit about these things, if
for instance you copied and pasted the code into another application,
perhaps written by someone else and were unaware they'd put say "DefInt
A-Z" up the top of the module then your untyped variable would default
to Integer. NASA lost a rocket this way :-)

--
This sig left intentionally blank
Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.