View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
MikeZz MikeZz is offline
external usenet poster
 
Posts: 152
Default How do I Run Macro on Opening if user is not the "Last Saved B

Hi Steve, Thanks for the help...

But what's difference between A & B?
Also, never heard of Wscript.Network but googled it....
Is there any benefit to using either of the following?

A: strUser = Application.UserName

B: Set objNetwork = CreateObject("Wscript.Network")
B: strUser = objNetwork.UserName
B: Set objNetwork = Nothing


"Steve Yandl" wrote:

Gary's Student,

I was just doing some testing of this while you were posting. Your line for
ActiveWorkbook.BuiltInDocumentProperties(7) works fine to retrieve the Last
Author (last saved by) but item(3) to retrieve 'Author' came up null for me
until the workbook was saved.

I think it might work better to use
strUser = Application.UserName
to get the name of the user registered for the Excel application used to
open the workbook, or
_________________
Set objNetwork = CreateObject("Wscript.Network")
strUser = objNetwork.UserName
Set objNetwork = Nothing
__________________
if you want the currently logged on user.

Steve



"Gary''s Student" wrote in message
...
If you have a Workbook Open Event macro, include lines like:

i = ActiveWorkbook.BuiltinDocumentProperties(3)
j = ActiveWorkbook.BuiltinDocumentProperties(7)
If i = j Then
Else
'run your first time code
End If
--
Gary''s Student - gsnu200745


"MikeZz" wrote:

Subject says it all.

Basically, I want to run a macro that applies various filters if a new
user
opens the file. If it's the same user that saved the file before, I
assume
they don't want the view to change.

Thanks,

MikeZz