Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 10th, 2004, 03:35 PM
Authorized User
 
Join Date: Sep 2004
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default Find a logon id

I want to export an Access report to Excel. When I do this, I need to save the new file as "C:\Documents and Settings\logon_ID\My Documents\newfile.xls"
I need to find the logon ID of the user. How can this be done?

Thanks, in advance

 
Old September 10th, 2004, 05:31 PM
sal sal is offline
Friend of Wrox
 
Join Date: Oct 2003
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts
Default

'put this in a module

Option Explicit
Option Compare Database

Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nsize As Long) As Long

Public str

Sub Get_User_Name()
    Dim lpBuff As String * 25
    Dim ret As Long, strUserName As String

    ret = GetUserName(lpBuff, 25)
    strUserName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
    Debug.Print Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
    str = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)

End Sub

'then you put this on your form


    Dim strCopyString As String



    Get_User_Name
    strCopyString = ""
    strCopyString = "C:\Documents and Settings\"
    strCopyString = strCopyString & str 'str comes from the module
    strCopyString = strCopyString & "\Desktop\file.txt"




This is what I use to put a file on the users desktop. Works like a charm.



Sal





Similar Threads
Thread Thread Starter Forum Replies Last Post
I can't find User Id and password for Chapter 6 jellyjune BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 3 September 21st, 2007 02:39 PM
identity column id find!! keyvanjan Classic ASP Basics 7 January 20th, 2007 01:12 PM
'this.ID = id;' in class construction holf BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 October 6th, 2006 10:58 AM
why not index.asp?id=1 can be www.myweb.com/?id=1 BurhanKhan Classic ASP Professional 11 September 6th, 2004 02:06 PM
Urgent please help to find Max ID and add 1 to it nhatrang71 Access 5 June 28th, 2004 10:24 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.