Using System.PrivateProfileString to obtain user info 
Author Message
 Using System.PrivateProfileString to obtain user info

Hi,
Am trying to implement some VBA code in Excel... found this code snippet on MSDN
and am wondering why it won't work:

The following macro displays the default user name setting from the Windows
registry:

Sub GetUserInfo()
   aName = System.PrivateProfileString("", _
   "HKEY_CURRENT_USER\Software\Microsoft\MS Setup (ACME)\User Info", _
   "DefName")
   MsgBox aName
End Sub

I have changed the above example for my worksheet project to read:

Private Sub CommandButton1_Click()
   Dim aName As String
   aName = System.PrivateProfileString
("", "HKEY_CURRENT_USER\Identities", "Default User ID")
   MsgBox aName
End Sub

Regardless of which code I use (the original or mine), when I run the code, I get
the following error:

Run-time error '424'
Object required

Am puzzled why I can't get this to work... any ideas out there?  Appreciate it!

Brant



Fri, 19 Sep 2003 22:16:35 GMT  
 Using System.PrivateProfileString to obtain user info
Hi Brant,

Remember to use an under-score: _  as a line delimiter in the code
at the end of your line 'aName = system...'

HTH,
W

Private Sub CommandButton1_Click()
   Dim aName As String
   aName = System.PrivateProfileString _    'HERE an under-score needed!
("", "HKEY_CURRENT_USER\Identities", "Default User ID")
   MsgBox aName
End Sub


Hi,
Am trying to implement some VBA code in Excel... found this code snippet on
MSDN
and am wondering why it won't work:

The following macro displays the default user name setting from the Windows
registry:

Sub GetUserInfo()
   aName = System.PrivateProfileString("", _
   "HKEY_CURRENT_USER\Software\Microsoft\MS Setup (ACME)\User Info", _
   "DefName")
   MsgBox aName
End Sub

I have changed the above example for my worksheet project to read:

Private Sub CommandButton1_Click()
   Dim aName As String
   aName = System.PrivateProfileString
("", "HKEY_CURRENT_USER\Identities", "Default User ID")
   MsgBox aName
End Sub

Regardless of which code I use (the original or mine), when I run the code,
I get
the following error:

Run-time error '424'
Object required

Am puzzled why I can't get this to work... any ideas out there?  Appreciate
it!

Brant



Sat, 20 Sep 2003 01:48:20 GMT  
 Using System.PrivateProfileString to obtain user info
Hi Brant,

the system object belongs to the word library, you'll have to resort to api
in excel (or reference the word object library) if you want the same
functionality.

but if you're lucky then this may be the info you need :

sub getuserinfo()
  msgbox interaction.Environ("username")
end sub

post back with more specifics if you need something else.

greetings, pieter.


Hi,
Am trying to implement some VBA code in Excel... found this code snippet on
MSDN
and am wondering why it won't work:

The following macro displays the default user name setting from the Windows
registry:

Sub GetUserInfo()
   aName = System.PrivateProfileString("", _
   "HKEY_CURRENT_USER\Software\Microsoft\MS Setup (ACME)\User Info", _
   "DefName")
   MsgBox aName
End Sub

I have changed the above example for my worksheet project to read:

Private Sub CommandButton1_Click()
   Dim aName As String
   aName = System.PrivateProfileString
("", "HKEY_CURRENT_USER\Identities", "Default User ID")
   MsgBox aName
End Sub

Regardless of which code I use (the original or mine), when I run the code,
I get
the following error:

Run-time error '424'
Object required

Am puzzled why I can't get this to work... any ideas out there?  Appreciate
it!

Brant



Mon, 22 Sep 2003 03:41:18 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Obtaining Info from Operating System

2. Obtaining system info over a network

3. Obtaining more NT user login info

4. Obtaining task info from API using VB4

5. Obtaining table info using ADO?

6. System.privateprofilestring?

7. System.PrivateProfileString

8. User viewing File System, how to get info from ActiveExplorer object

9. Operating System and User profile info?

10. Using PrivateProfileString

11. Using System Info in a Project

12. How to get font info from system using SystemParametersInfo API

 

 
Powered by phpBB® Forum Software