Getting open file's directory, captureing user login ID, write access

C

Claud Balls

I have a few questions.
1: How can I get the directory for the currently opened excel file?
2: Is there a way to capture the login ID for the user currently using
the excel macro?
3: Is there a way to only let data be written to a spreadsheet via a
user form?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
B

Bob Phillips

1. ActiveWorkbook.Path

2. Here is a simple function that returns the network user id
Public Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" _
(ByVal lpBuffer As String, _
nSize As Long) As Long


Public Function UserName() As String
Dim sName As String * 256
Dim cChars As Long
cChars = 256
If GetUserName(sName, cChars) Then
UserName = Left$(sName, cChars - 1)
End If
End Function

3. Probably need to protect it, and remove the protection when you want to
write to it, then re-apply it.


--

HTH

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

Claud Balls

I just tried out your first two suggestions, EXCELLENT HELP!! thank you
and Merry Christmas. I have yet to deal with #3.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 

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