News:

Tekforums.net - The improved home of Tekforums! :D

Main Menu

Grabbing current username macro?

Started by M3ta7h3ad, May 13, 2006, 10:25:37 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

M3ta7h3ad

I am doing a little tweaking of an excel document we use in work. Basically want to automate the filling out of any fields I can.

Ive got the current time and date working fine, but theres a "packed by" box, which tends to be filled in with the initials of the person who opened it.

Is there anyway of getting this information from a macro? So the currently logged in user gets listed in the "Packed by" Field?

madmax

ive done it the other way round quite a few times....

in that ive made a vb6 interface program and let that generate an excel sheet.
use that to generate replacement reports they get on the current system.


if you need some details lemme know,
but its as simple as declaring  xlapp as new excel.application and adding workbook and sheets to it.

anything you can do in excel you can call from vb6

Mardoni

I dont think you can pull the username from a macro but it is certainly avalible from an API call.

M3ta7h3ad

:(

Its just an excel spreadsheet that gets sent out to our sales staff for them to email a copy in filled out when they need some more stationary and stuff :) Cant make it an application but just want it to grab the current windows login and shove it in the field :) so that when the packers print off the order sheet it gives their names there.

BigSoy

Its available from the ENVIRON function in Excel.

Use something like this:


Function UserNameWindows() As String
    UserNameWindows = Environ("USERNAME")
End Sub


I dont have Excel on this box at the moment but I tried that in word and Im reasonably convinced the same thing is available in Excel.
"Within your 'purview'? Where do you think you are, some f**king regency costume drama? This is a government department, not some f**king Jane f**king Austen novel!"