You can grab the user name on of two ways:
Via API:
Private Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" (ByVal Buffer As String, Size As Long) As Long
Public Function Get USER_NAME() As String
'Author: Duane Hennessy
'Date: 7.4.2003
'Description: Returns the user name
'Requirements: GetUserName
On Error Resume Next
Dim strUserName As String
Const lngcLength As Long = 255
Dim lngResult As Long
strUserName = String(255, 0)
lngResult = GetUserName(strUserName, lngcLength)
USER_NAME = left$(strUserName, InStr(1, strUserName, Chr(0)) - 1)
End Function
Or you can use the _vbscript_ version (which I prefer for less messy API code etc.)
Public Function User_Name as String
'Author: Duane Hennessy
'Company: Bandicoot Software, Australia
'Date: 25/1/06, 4:57 AM
'Description: self_explanatory_title
'Notes: You can also use this Net object to get _
' Net.ComputerName _
Net.UserDomain
On Error Resume Next
Dim Net as Object
Set Net = CreateObject("WScript.NetWork")
If Not Net is Nothing then
User_Name = Net.UserName
Set objNet = Nothing
End If
End Function
Hope this helps
Duane Hennessy
Bandicoot Software
Tropical Queensland, Australia
(ABN: 33 682 969 957)
Why recode the wheel?
http://www.bandicootsoftware.com.au
All I can suggest is that
--- In AccessDevelopers@yahoogroups.com, "Hoffman, Tobi K \(DYS\)" <[EMAIL PROTECTED]> wrote:
>
> Duane,
>
> I've put the code in my program, but it doesn't seem to fit our setup
> here. Nobody (except me, by special arrangement!) actually sees their
> own C: drive, but rather a virtual desktop that is actually on a server,
> so the path to my "My Documents" folder is actually
>
> \EHS-xxxxx-001\users$\tkhoffman\mydocs
>
> If I could get the computer name part, "tkhoffman" in my case, then I
> can put it in the middle of this text and have that as the default
> location for saving files. With your code, what I get for the path to
> "My Documents" is
>
> C:\Documents and Settings\AllUsers\Desktop
>
> which will not do any good in this setup. (I've mentioned how little I
> like this situation, but it's entrenched!)
>
> Is there another variable I can add to your code to get the user name?
>
> Tobi
>
> -----Original Message-----
> From: AccessDevelopers@yahoogroups.com
> [mailto:[EMAIL PROTECTED] On Behalf Of Duane Hennessy
> Sent: Monday, January 23, 2006 5:37 PM
> To: AccessDevelopers@yahoogroups.com
> Subject: [AccessDevelopers] Finding paths to special folders.
>
>
>
> Due to Tobi's request I've quickly created and uploaded a
> System_Folders class (see link below). This class provides a list of
> all of the Windows Special Folders so you can get their folder paths.
>
> Anyhow basically all you have to do is... Insert a class object
> into your database modules and paste the code into it. To use it do the
> following:
>
> Dim sysFolders as New System_Folders
> msgbox sysFolders.folder_path_for(MYDOCUMENTS)
>
> A list of possible system folders will appear when you open the
> bracket (.
>
>
> http://f4.grp.yahoofs.com/v1/4FHVQ4kQ1rqHJFLyFUR65wLhtvmZ9qtEvwq2Vvijn74
> saYccEq_iiXW6GQzag684FMug7RWJGPvmKAHl_O8/Handy%20Classes/System_Folders.
> txt
>
> Hasta luego,
> <http://us.i1.yimg.com/us.yimg.com/i/mesg/tsmileys2/01.gif>
>
> Duane Hennessy.
> Bandicoot Software
> Tropical Queensland, Australia
> (ABN: 33 682 969 957)
>
> Want Increased Productivity?
> http://www.bandicootsoftware.com.au
> <http://www.bandicootsoftware.com.au>
>
>
>
>
> Please zip all files prior to uploading to Files section.
>
>
>
> _____
>
> YAHOO! GROUPS LINKS
>
>
>
> * Visit your group "AccessDevelopers
> <http://groups.yahoo.com/group/AccessDevelopers> " on the web.
>
> * To unsubscribe from this group, send an email to:
> [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]
> >
>
> * Your use of Yahoo! Groups is subject to the Yahoo!
> Terms of Service <http://docs.yahoo.com/info/terms/> .
>
>
> _____
>
Please zip all files prior to uploading to Files section.
SPONSORED LINKS
Microsoft access developer | Microsoft access help | Microsoft access database |
Microsoft access training | Microsoft access training course | Microsoft access programming |
YAHOO! GROUPS LINKS
- Visit your group "AccessDevelopers" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.