PDA

View Full Version : check dir w/ account names



Trevor
03-19-2008, 11:43 AM
I am trying to check to see if a file exsists/open, note where the * is , is where the user account name would be(and it can be anyone account, so it would be a wild card.
[VBA]
If Len("C:\Documents and Settings\*.*\Desktop") = 1
[\VBA]
[VBA]
If Len("C:\Documents and Settings\" * "\Desktop") = 1
[\VBA]
nither of the above work for me
I'm thinking I should have vbcompare in my arg somewhere.

Norie
03-19-2008, 11:54 AM
Why would they work?:huh:

Len is used to return the length of a string, it has nothing to do with files unless combined with other functions.

Perhaps you should be looking at the Dir function.

Trevor
03-19-2008, 12:10 PM
len is also used for counting though and can see if a dir exsists that way.
what do propose I change I syntax too?

Norie
03-19-2008, 12:22 PM
Trevor

The only thing that Len is used to count is the number of characters in a string.

I'm not sure what to propose you use as it isn't actually clear what you want to do.

That's mainly because of your use of a wildcard and also why the folder, wildcard(s) and then what appears to be another folder(Desktop).

Trevor
03-19-2008, 09:35 PM
ok your right, on secand look in my hast to post it maid since to me, but now that i step back and look at what i wrote I can see how it may not make since
I wan't to check a to see if a file is file is open that is on the desktop.
because this db will be on a lan the acount name in the path will change along with the file name that I want to check on the deuktop, but the file on the desktop that I want to check to see if it is open, the name of thaofile will be on form!form1![reportname]
the second to see if a file is open ( i learned after writing this that the file could be anywhere one c:\ (because I don't know the file name right now I'lll just say the name Of the file I want to see if it exsists is "FileName"
Thanks, Trevor

akn112
03-20-2008, 12:04 PM
try


If Len(dir("C:\Documents and Settings\" & environ("username") & "\Desktop\myfile.txt")) > 0 then
'my file exists
end if

Trevor
03-20-2008, 01:00 PM
akn112 thanks, that brings up another question, since I have been playing with environ("username").
how can I get the users actual name (I want to use the first name in this cast)? for example the user name may be JSmith, there real name is john smith, but when you click the startbar, their name comes up as Smith, john A.

akn112
03-24-2008, 12:39 PM
hmm...i've never tried that before. I'd run a google search on it. Something around the lines of "display name" or "profile name". Another way is to make a reference table. Unfortunately, thats a completely manual process.

Trevor
03-24-2008, 05:46 PM
the closet I have found is how to get the office users name, but since this is on a company pc , its not the first name of the user I'm going ea get