Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Supressing MsgBox poop-ups from VBA

Hi All

I have added a MsgBox message to my system on Workbook_Open to display
a message if the user has opened the system in read-only. The message
just warns them that they cannot make changes. This works fine.

I have now written a report generator which opens the main system in
read-only mode to collect the data. The problem is that my report
generator also gets the read-only message and therefore waits for me
to click "OK".

How can I supress this message from my report generator code yet still
have it pop up for a normal user?

Application.DisplayAlerts = False does not solve the problem as my
message is a MsgBox and not an Excel alert.

Any ideas? Thanks in advance,
Chrisso

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Supressing MsgBox poop-ups from VBA

You can set your username in Excel to something unique and then use an
If statement to check for it before displaying the message box.
Something like
If Application.Username < "something_unique" Then MsgBox("Whatever")

You can change you username by going to Tools--Options and selecting
the General tab. Please not that there are other ways of doing this
as well.
Hi All

I have added a MsgBox message to my system on Workbook_Open to display
a message if the user has opened the system in read-only. The message
just warns them that they cannot make changes. This works fine.

I have now written a report generator which opens the main system in
read-only mode to collect the data. The problem is that my report
generator also gets the read-only message and therefore waits for me
to click "OK".

How can I supress this message from my report generator code yet still
have it pop up for a normal user?

Application.DisplayAlerts = False does not solve the problem as my
message is a MsgBox and not an Excel alert.

Any ideas? Thanks in advance,
Chrisso


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Supressing MsgBox poop-ups from VBA

I'd suggest setting any other kind of flag. Messing with the username might
have unexpected consequences. Wouldn't it be funny to view a cell comment
and have "something_unique" appear in the status bar?

For example, set some kind of global boolean to true. Or put a dummy text
file named "OmitMsgBox.txt" in the program directory only on your machine or
when you're running in auto mode. Use Dir() to test for the presence of the
file. If it's there, then don't show the message box.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"JW" wrote in message
oups.com...
You can set your username in Excel to something unique and then use an
If statement to check for it before displaying the message box.
Something like
If Application.Username < "something_unique" Then MsgBox("Whatever")

You can change you username by going to Tools--Options and selecting
the General tab. Please not that there are other ways of doing this
as well.
Hi All

I have added a MsgBox message to my system on Workbook_Open to display
a message if the user has opened the system in read-only. The message
just warns them that they cannot make changes. This works fine.

I have now written a report generator which opens the main system in
read-only mode to collect the data. The problem is that my report
generator also gets the read-only message and therefore waits for me
to click "OK".

How can I supress this message from my report generator code yet still
have it pop up for a normal user?

Application.DisplayAlerts = False does not solve the problem as my
message is a MsgBox and not an Excel alert.

Any ideas? Thanks in advance,
Chrisso




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 284
Default Supressing MsgBox poop-ups from VBA

One option would be to use the popup method of the windows script host shell
object instead of a MsgBox, allowing you to set a timeout for the window.
What I've got below will produce what looks almost identical to a regular
message box with an OK button and a timeout of 5 seconds if the user doesn't
take action.

____________________________________

Set wsh = CreateObject("WScript.Shell")
intRet = wsh.Popup("Opened as Read Only", 5, "Notification", 0)
Set wsh = Nothing
____________________________________

Steve



"Chrisso" wrote in message
ps.com...
Hi All

I have added a MsgBox message to my system on Workbook_Open to display
a message if the user has opened the system in read-only. The message
just warns them that they cannot make changes. This works fine.

I have now written a report generator which opens the main system in
read-only mode to collect the data. The problem is that my report
generator also gets the read-only message and therefore waits for me
to click "OK".

How can I supress this message from my report generator code yet still
have it pop up for a normal user?

Application.DisplayAlerts = False does not solve the problem as my
message is a MsgBox and not an Excel alert.

Any ideas? Thanks in advance,
Chrisso



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Supressing MsgBox poop-ups from VBA

Jon, you make a good point. But, I wasn't meaning to really use
"something_unique" as the name. He could use "John_A_Smith" (using
his real name of course) or something of that nature.
Steve Yandl wrote:
One option would be to use the popup method of the windows script host shell
object instead of a MsgBox, allowing you to set a timeout for the window.
What I've got below will produce what looks almost identical to a regular
message box with an OK button and a timeout of 5 seconds if the user doesn't
take action.

____________________________________

Set wsh = CreateObject("WScript.Shell")
intRet = wsh.Popup("Opened as Read Only", 5, "Notification", 0)
Set wsh = Nothing
____________________________________

Steve



"Chrisso" wrote in message
ps.com...
Hi All

I have added a MsgBox message to my system on Workbook_Open to display
a message if the user has opened the system in read-only. The message
just warns them that they cannot make changes. This works fine.

I have now written a report generator which opens the main system in
read-only mode to collect the data. The problem is that my report
generator also gets the read-only message and therefore waits for me
to click "OK".

How can I supress this message from my report generator code yet still
have it pop up for a normal user?

Application.DisplayAlerts = False does not solve the problem as my
message is a MsgBox and not an Excel alert.

Any ideas? Thanks in advance,
Chrisso




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Supressing MsgBox poop-ups from VBA

There are a lot of ways to approach this. Hard-coding a specific username
limits the behavior to the one user, which may be okay, but if someone takes
over the project, you have to find all hard-coded strings, and if you want
to allow someone else to use the modified behavior, you have to make the
comparison more complicated, looking for either John Smith or Jane Doe as
username. Using an external dummy file is pretty easy. You could also store
the setting in an INI file, the registry, or some other location, so the
program could check whether or not to do something. You know the little
checkbox on some dialogs, "Don't show this again"? That's how the program
known not to show this again.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"JW" wrote in message
ups.com...
Jon, you make a good point. But, I wasn't meaning to really use
"something_unique" as the name. He could use "John_A_Smith" (using
his real name of course) or something of that nature.
Steve Yandl wrote:
One option would be to use the popup method of the windows script host
shell
object instead of a MsgBox, allowing you to set a timeout for the window.
What I've got below will produce what looks almost identical to a regular
message box with an OK button and a timeout of 5 seconds if the user
doesn't
take action.

____________________________________

Set wsh = CreateObject("WScript.Shell")
intRet = wsh.Popup("Opened as Read Only", 5, "Notification", 0)
Set wsh = Nothing
____________________________________

Steve



"Chrisso" wrote in message
ps.com...
Hi All

I have added a MsgBox message to my system on Workbook_Open to display
a message if the user has opened the system in read-only. The message
just warns them that they cannot make changes. This works fine.

I have now written a report generator which opens the main system in
read-only mode to collect the data. The problem is that my report
generator also gets the read-only message and therefore waits for me
to click "OK".

How can I supress this message from my report generator code yet still
have it pop up for a normal user?

Application.DisplayAlerts = False does not solve the problem as my
message is a MsgBox and not an Excel alert.

Any ideas? Thanks in advance,
Chrisso




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
How can I use AutoFilter without supressing rows ? Alexandre Excel Discussion (Misc queries) 1 March 5th 07 09:44 PM
Supressing SpellChecker dialogbox davidm Excel Programming 2 October 27th 05 08:20 AM
supressing system warning messages ppete83606[_2_] Excel Programming 3 September 15th 05 05:21 AM
Do you poop? whatsupppppppp???????????? Excel Discussion (Misc queries) 0 June 16th 05 09:10 PM
supressing a message in vba Rob Hargreaves[_2_] Excel Programming 2 June 11th 05 11:11 AM


All times are GMT +1. The time now is 09:53 PM.

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

About Us

"It's about Microsoft Excel"