ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   A double check, please (https://www.excelbanter.com/excel-programming/327928-double-check-please.html)

Stuart[_21_]

A double check, please
 
If I say:
If Len(Dir(Application.Path & "\" & "abc.exe")) _
= 0 Then
Exit Sub
Else
etc
End If

Can I reliably assume that Exit Sub will only occur if the file 'abc.exe' is
not found in the Office-installed path?
....not a trick question, just wish to know what I can be sure of, if I make
the statement.

Regards.




Jim Thomlinson[_3_]

A double check, please
 
Generally speaking that will work for you. The only areas that I wonder about
is did you mean Application.path or thisworkbook.path? Application.path is
the directory where the Excel.exe file is stored and normally you do not save
a lot of stuff in there... (not necessarily wrong, just curious). The other
comment is that you do not need to do that as an if - then - else. It could
be written

If Len(Dir(Application.Path & "\" & "abc.exe")) = 0 Then Exit Sub

etc

HTH


"Stuart" wrote:

If I say:
If Len(Dir(Application.Path & "\" & "abc.exe")) _
= 0 Then
Exit Sub
Else
etc
End If

Can I reliably assume that Exit Sub will only occur if the file 'abc.exe' is
not found in the Office-installed path?
....not a trick question, just wish to know what I can be sure of, if I make
the statement.

Regards.





Stephen Bullen[_4_]

A double check, please
 
Hi Stuart,

If I say:
If Len(Dir(Application.Path & "\" & "abc.exe")) _
= 0 Then
Exit Sub
Else
etc
End If

Can I reliably assume that Exit Sub will only occur if the file 'abc.exe' is
not found in the Office-installed path?


Yep (in the path of the Excel.exe file).

Regards

Stephen Bullen
Microsoft MVP - Excel

Professional Excel Development
The most advanced Excel VBA book available
www.oaltd.co.uk/ProExcelDev



Stuart[_21_]

A double check, please
 
Many thanks.
I'm trying to check the file exists... so
If abc.exe exists 'ok
Else MsgBox "You need to install abc.exe"
Exit Sub
End If
was my logic.

There are actually 2 files I'm looking for. I believe both are Optional
rather than Default choices during an Office install. I believe both files
(if installed during the initial Office install .... or later, via
Add/Remove Features) will
reside in Application.Path. However there may well be Office version issues
to deal with.

What do you think, please?

Regards.

"Jim Thomlinson" wrote in message
...
Generally speaking that will work for you. The only areas that I wonder
about
is did you mean Application.path or thisworkbook.path? Application.path is
the directory where the Excel.exe file is stored and normally you do not
save
a lot of stuff in there... (not necessarily wrong, just curious). The
other
comment is that you do not need to do that as an if - then - else. It
could
be written

If Len(Dir(Application.Path & "\" & "abc.exe")) = 0 Then Exit Sub

etc

HTH


"Stuart" wrote:

If I say:
If Len(Dir(Application.Path & "\" & "abc.exe")) _
= 0 Then
Exit Sub
Else
etc
End If

Can I reliably assume that Exit Sub will only occur if the file 'abc.exe'
is
not found in the Office-installed path?
....not a trick question, just wish to know what I can be sure of, if I
make
the statement.

Regards.







Bob Phillips[_6_]

A double check, please
 
The only comment I would (gently) make is, why ask, why not just try and
find out for yourself. A bit of testing will prove the answer, and you will
learn more than just by being told.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Stuart" wrote in message
...
If I say:
If Len(Dir(Application.Path & "\" & "abc.exe")) _
= 0 Then
Exit Sub
Else
etc
End If

Can I reliably assume that Exit Sub will only occur if the file 'abc.exe'

is
not found in the Office-installed path?
...not a trick question, just wish to know what I can be sure of, if I

make
the statement.

Regards.






Jim Thomlinson[_3_]

A double check, please
 
That logic looks good. If you are looking for two files why not something like

If len(dir(ABC.exe)) < 0 and len(dir(CDE.exe)) < 0 then
'both files exist
'Do whatever you want to do
elseif len(dir(ABC.exe)) = 0
msgbox "ABC.exe does not exist"
else
msgbox "CDE.exe does not exist"
endif

Gets rid of that sometimes pesky exit sub... As for the files existing in
the application directory that sounds entirely resonable to me.

HTH

"Stuart" wrote:

Many thanks.
I'm trying to check the file exists... so
If abc.exe exists 'ok
Else MsgBox "You need to install abc.exe"
Exit Sub
End If
was my logic.

There are actually 2 files I'm looking for. I believe both are Optional
rather than Default choices during an Office install. I believe both files
(if installed during the initial Office install .... or later, via
Add/Remove Features) will
reside in Application.Path. However there may well be Office version issues
to deal with.

What do you think, please?

Regards.

"Jim Thomlinson" wrote in message
...
Generally speaking that will work for you. The only areas that I wonder
about
is did you mean Application.path or thisworkbook.path? Application.path is
the directory where the Excel.exe file is stored and normally you do not
save
a lot of stuff in there... (not necessarily wrong, just curious). The
other
comment is that you do not need to do that as an if - then - else. It
could
be written

If Len(Dir(Application.Path & "\" & "abc.exe")) = 0 Then Exit Sub

etc

HTH


"Stuart" wrote:

If I say:
If Len(Dir(Application.Path & "\" & "abc.exe")) _
= 0 Then
Exit Sub
Else
etc
End If

Can I reliably assume that Exit Sub will only occur if the file 'abc.exe'
is
not found in the Office-installed path?
....not a trick question, just wish to know what I can be sure of, if I
make
the statement.

Regards.








Stuart[_21_]

A double check, please
 
Thanks.
I do generally try...... well, try the ng, perhaps <g,
but here I was not at all sure what Application.path
means.....and I'm not sure I do now.

eg, if a user has a suite of Office applications installed, then if the code
is run from Word, where does the path point to? and if from Excel?
Presumably if only Excel is installed, then it would point to wherever
Excel.exe is installed?

Code was not the issue for the op, but what exactly
Application.path might point to.

Regards.

"Bob Phillips" wrote in message
...
The only comment I would (gently) make is, why ask, why not just try and
find out for yourself. A bit of testing will prove the answer, and you
will
learn more than just by being told.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Stuart" wrote in message
...
If I say:
If Len(Dir(Application.Path & "\" & "abc.exe")) _
= 0 Then
Exit Sub
Else
etc
End If

Can I reliably assume that Exit Sub will only occur if the file 'abc.exe'

is
not found in the Office-installed path?
...not a trick question, just wish to know what I can be sure of, if I

make
the statement.

Regards.








Stuart[_21_]

A double check, please
 
Thanks again.
I actually had:
If Len(Dir(Application.Path & "\" & "makecert.exe")) _
= 0 _
Or Len(Dir(Application.Path & "\" & "signer.dll")) _
= 0 Then
MsgBox "etc"
Exit sub
Else
etc
end If

BTW a very big help: where can I download 'signer.dll'?
I'm trying to develop a wrapper by which I can create
Self Certificates.....cannot find this file anywhere (thought it was with
SDK).

Regards and thanks again.

"Jim Thomlinson" wrote in message
...
That logic looks good. If you are looking for two files why not something
like

If len(dir(ABC.exe)) < 0 and len(dir(CDE.exe)) < 0 then
'both files exist
'Do whatever you want to do
elseif len(dir(ABC.exe)) = 0
msgbox "ABC.exe does not exist"
else
msgbox "CDE.exe does not exist"
endif

Gets rid of that sometimes pesky exit sub... As for the files existing in
the application directory that sounds entirely resonable to me.

HTH

"Stuart" wrote:

Many thanks.
I'm trying to check the file exists... so
If abc.exe exists 'ok
Else MsgBox "You need to install abc.exe"
Exit Sub
End If
was my logic.

There are actually 2 files I'm looking for. I believe both are Optional
rather than Default choices during an Office install. I believe both
files
(if installed during the initial Office install .... or later, via
Add/Remove Features) will
reside in Application.Path. However there may well be Office version
issues
to deal with.

What do you think, please?

Regards.

"Jim Thomlinson" wrote in
message
...
Generally speaking that will work for you. The only areas that I wonder
about
is did you mean Application.path or thisworkbook.path? Application.path
is
the directory where the Excel.exe file is stored and normally you do
not
save
a lot of stuff in there... (not necessarily wrong, just curious). The
other
comment is that you do not need to do that as an if - then - else. It
could
be written

If Len(Dir(Application.Path & "\" & "abc.exe")) = 0 Then Exit Sub

etc

HTH


"Stuart" wrote:

If I say:
If Len(Dir(Application.Path & "\" & "abc.exe")) _
= 0 Then
Exit Sub
Else
etc
End If

Can I reliably assume that Exit Sub will only occur if the file
'abc.exe'
is
not found in the Office-installed path?
....not a trick question, just wish to know what I can be sure of, if
I
make
the statement.

Regards.










Bob Phillips[_6_]

A double check, please
 
I see, not really what you asked <bg

Further clarification on Application then. The Application object refers to
the VBA host application, be that Excel, Word or whatever. So when run on
the Excel application (which doesn't necessarily mean in Excel),
Application.Path refers to the Excel.exe directory, on Word it is the
Word,exe directory (which may not be the same). Also, remember that each
product will install other files in related directories, such as XLStart,
Addins, etc., so it can get complex, especially as MS moved to using
Documents and Settings.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Stuart" wrote in message
...
Thanks.
I do generally try...... well, try the ng, perhaps <g,
but here I was not at all sure what Application.path
means.....and I'm not sure I do now.

eg, if a user has a suite of Office applications installed, then if the

code
is run from Word, where does the path point to? and if from Excel?
Presumably if only Excel is installed, then it would point to wherever
Excel.exe is installed?

Code was not the issue for the op, but what exactly
Application.path might point to.

Regards.

"Bob Phillips" wrote in message
...
The only comment I would (gently) make is, why ask, why not just try and
find out for yourself. A bit of testing will prove the answer, and you
will
learn more than just by being told.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Stuart" wrote in message
...
If I say:
If Len(Dir(Application.Path & "\" & "abc.exe")) _
= 0 Then
Exit Sub
Else
etc
End If

Can I reliably assume that Exit Sub will only occur if the file

'abc.exe'
is
not found in the Office-installed path?
...not a trick question, just wish to know what I can be sure of, if I

make
the statement.

Regards.










Stuart[_21_]

A double check, please
 
I see, not really what you asked <bg
Oops, done it again (vbg allround).

Thanks for the clarification.

Regards.

"Bob Phillips" wrote in message
...
I see, not really what you asked <bg

Further clarification on Application then. The Application object refers
to
the VBA host application, be that Excel, Word or whatever. So when run on
the Excel application (which doesn't necessarily mean in Excel),
Application.Path refers to the Excel.exe directory, on Word it is the
Word,exe directory (which may not be the same). Also, remember that each
product will install other files in related directories, such as XLStart,
Addins, etc., so it can get complex, especially as MS moved to using
Documents and Settings.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Stuart" wrote in message
...
Thanks.
I do generally try...... well, try the ng, perhaps <g,
but here I was not at all sure what Application.path
means.....and I'm not sure I do now.

eg, if a user has a suite of Office applications installed, then if the

code
is run from Word, where does the path point to? and if from Excel?
Presumably if only Excel is installed, then it would point to wherever
Excel.exe is installed?

Code was not the issue for the op, but what exactly
Application.path might point to.

Regards.

"Bob Phillips" wrote in message
...
The only comment I would (gently) make is, why ask, why not just try
and
find out for yourself. A bit of testing will prove the answer, and you
will
learn more than just by being told.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Stuart" wrote in message
...
If I say:
If Len(Dir(Application.Path & "\" & "abc.exe")) _
= 0 Then
Exit Sub
Else
etc
End If

Can I reliably assume that Exit Sub will only occur if the file

'abc.exe'
is
not found in the Office-installed path?
...not a trick question, just wish to know what I can be sure of, if I
make
the statement.

Regards.













All times are GMT +1. The time now is 06:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com