Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 718
Default Sub Not Working

Here's the code I'm working with...

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

If Application.UserName < rcj Then

Cancel = True
MsgBox "Sorry, But You Don't Have Permission To Save This File",
vbExclamation, "Invalid Permission"

End If

MsgBox Application.UserName

End Sub

I get the error and it doesn't save, but if I use ... Application.UserName =
rcj Then I get to save but that's backwards I want it to elvaluate what the
username is and if it's not my username than it cancels the save and lets the
user know. Why is it working backwards?

Thanks,
Rob
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Sub Not Working

If Application.UserName < "rcj" Then
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Rob"
wrote in message
Here's the code I'm working with...

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Application.UserName < rcj Then
Cancel = True
MsgBox "Sorry, But You Don't Have Permission To Save This File",
vbExclamation, "Invalid Permission"
End If
MsgBox Application.UserName
End Sub

I get the error and it doesn't save, but if I use ... Application.UserName =
rcj Then I get to save but that's backwards I want it to elvaluate what the
username is and if it's not my username than it cancels the save and lets the
user know. Why is it working backwards?
Thanks,
Rob
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Sub Not Working

If Application.UserName < "rcj" Or Application.UserName < "pbcj" Then

hth,

tim

"Rob" wrote in message
...
HA! I feel sooo silly.

Thanks.

What if i wanted to add another username to ba allowed to save (i.e.
pbcj)?
I tried below but I get a type mismatch runtime error 13.

If Application.UserName < "rcj" Or "pbcj" Then


Rob


"Don Guillett" wrote:

try < "rcj"

--
Don Guillett
SalesAid Software

"Rob" wrote in message
...
Here's the code I'm working with...

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)

If Application.UserName < rcj Then

Cancel = True
MsgBox "Sorry, But You Don't Have Permission To Save This File",
vbExclamation, "Invalid Permission"

End If

MsgBox Application.UserName

End Sub

I get the error and it doesn't save, but if I use ...
Application.UserName
=
rcj Then I get to save but that's backwards I want it to elvaluate
what
the
username is and if it's not my username than it cancels the save and
lets
the
user know. Why is it working backwards?

Thanks,
Rob








  #6   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 718
Default Sub Not Working

Thanks Tim, But when I incorporate that string it gives be the permission
error. If I remove the additional user from it the it works again. it seems
like I can only have one user.

Any other ideas?

Thanks tons,
Rob



"Tim Marsh" wrote:

If Application.UserName < "rcj" Or Application.UserName < "pbcj" Then

hth,

tim

"Rob" wrote in message
...
HA! I feel sooo silly.

Thanks.

What if i wanted to add another username to ba allowed to save (i.e.
pbcj)?
I tried below but I get a type mismatch runtime error 13.

If Application.UserName < "rcj" Or "pbcj" Then


Rob


"Don Guillett" wrote:

try < "rcj"

--
Don Guillett
SalesAid Software

"Rob" wrote in message
...
Here's the code I'm working with...

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)

If Application.UserName < rcj Then

Cancel = True
MsgBox "Sorry, But You Don't Have Permission To Save This File",
vbExclamation, "Invalid Permission"

End If

MsgBox Application.UserName

End Sub

I get the error and it doesn't save, but if I use ...
Application.UserName
=
rcj Then I get to save but that's backwards I want it to elvaluate
what
the
username is and if it's not my username than it cancels the save and
lets
the
user know. Why is it working backwards?

Thanks,
Rob






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Sub Not Working

there is a logic error in the statement. Try

If Application.UserName < "rcj" and Application.UserName < "pbcj" Then


One statement will always be false, so you can't use OR.

--
Regards,
Tom Ogilvy

"Rob" wrote in message
...
Thanks Tim, But when I incorporate that string it gives be the permission
error. If I remove the additional user from it the it works again. it
seems
like I can only have one user.

Any other ideas?

Thanks tons,
Rob



"Tim Marsh" wrote:

If Application.UserName < "rcj" Or Application.UserName < "pbcj" Then

hth,

tim

"Rob" wrote in message
...
HA! I feel sooo silly.

Thanks.

What if i wanted to add another username to ba allowed to save (i.e.
pbcj)?
I tried below but I get a type mismatch runtime error 13.

If Application.UserName < "rcj" Or "pbcj" Then


Rob


"Don Guillett" wrote:

try < "rcj"

--
Don Guillett
SalesAid Software

"Rob" wrote in message
...
Here's the code I'm working with...

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)

If Application.UserName < rcj Then

Cancel = True
MsgBox "Sorry, But You Don't Have Permission To Save This File",
vbExclamation, "Invalid Permission"

End If

MsgBox Application.UserName

End Sub

I get the error and it doesn't save, but if I use ...
Application.UserName
=
rcj Then I get to save but that's backwards I want it to elvaluate
what
the
username is and if it's not my username than it cancels the save and
lets
the
user know. Why is it working backwards?

Thanks,
Rob








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculate working days but change working week SamB Excel Discussion (Misc queries) 1 September 1st 08 09:17 PM
Making weekend days working days - the system cuts the working tim Fluffy Excel Discussion (Misc queries) 1 May 30th 08 10:02 PM
macro was working, now it's not working RichardO[_11_] Excel Programming 2 June 9th 04 06:27 AM
Macro working in Excel 2003; not working in Excel 2000 Leslie Barberie Excel Programming 5 May 20th 04 07:51 PM
Adding sales from a non working day to the previous working day Alex Excel Programming 1 September 19th 03 08:48 AM


All times are GMT +1. The time now is 07:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"