"Dir" statement in VBScript ...

G

Guest

.... does it work? I'm getting an error (type mismatch) and don'ty know if
I've used it incorrectly or if it simply doesn't work in VBS.
 
S

Sue Mosher [MVP-Outlook]

My point is that if the original poster shows their code and thereby what
they're trying to accomplish, it should be possible to steer them in the
right direction.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

Sue, I can definitely see where you're coming from with this. That's why I
originally wrote my question like this:
I have a custom form with a combo-box control. The Combo-box is populated
with data from an Access database using DAO. It works fine, but there's one
minor issue with remote users. If they aren't connected to the company
network, they obviously can't populate the combo-box and the form errors out,
which is fine, but r_e_a_l_l_y s_l_o_w_l_y, which is not fine.

The problem is that the error is generated by this line of code:

Set DatBase = DBEngine.OpenDatabase(strDBPath & strDBName)

I'm sure if I knew how to test whether strDBPath was a valid path before
calling the OpenDatabase object, it would be seconds quicker, but I don't
know how to do it. This must be easy, but I don't really know where to start
with it.

Can anyone advise?

Thanks in advance

Vaughan

But that didn't excite anyone enough to get a response. Having posted about
20 or so questions to this group over six months, I have found that when I
give a full explanation of what I'm trying to do nobody answers. If I then
boil the question down to a couple of lines, I usually get exactly what I
need (more often than not from you Sue. And believe me, I couldn't be more
grateful for all your help.)

In this case, the ploy only worked up to a point. Wolfram has answered my
specific question (thanks Wolfie) but, as you spotted, that doesn't resolve
my overall problem of how to test whether the path to my database is valid
when I run the form. If you (or anyone) can give me a solution to that, I
would be most extremely grateful.

Thanks again for your interest and help

Vaughan
 
W

Wolfram Jahn

Hi,

you could have added one short question to your OP, e.g.
... does it work? I'm getting an error (type mismatch)
and don'ty know if I've used it incorrectly or if it
simply doesn't work in VBS. +++
Any other chance to get file/dir information?
---

Short and clear.

If you ask if dir does/doesn't work then the answer that dir doesn't
exist is exact. I do not want to guess your questions.

Now that you asked, did you consider to use scripting?

http://msdn.microsoft.com/library/d...ript56/html/sgprogrammingfilesystemobject.asp

found there:

Function ReportFileStatus(filespec)
Dim fso, msg
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists(filespec)) Then
msg = filespec & " exists."
Else
msg = filespec & " doesn't exist."
End If
ReportFileStatus = msg
End Function


Kind regards

Wolfram
 
G

Guest

Hi Wolfram

You are absolutely right, I will make sure my osts are more carefully worded
in the future.

And thanks for our suggestions which seems to do exactly what I wanted. I
just have one question. To make it work on my machine I had to add the
Scriting runtime Library to the list of references in Outlook. Will I need to
do this for everyone who uses the form, or can I get the library to be added
by coding it in the form somehow?

Thanks

Vaughan
 
W

Wolfram Jahn

Vaughan said:
To make it work on my machine I had to add the
Scriting runtime Library to the list of references in Outlook.

If you use vbscript code in a custom form you need no reference in Outlook.
Will I need to
do this for everyone who uses the form, or can I get the library to be added
by coding it in the form somehow?

I just checked it - I had not even to open the vba editor, just
customized a form, and the code ran.

If you like, I will send an example .oft file by email.

Wolfram
 
G

Guest

Thanks Wolfman

I tested the form on some other pcs around here and they all worked fine.
The code I already have works fine too, so you don't need to email the .oft
file.


I think this one is resolved now.

Best regards

Vaughan
 

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