Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Stopping error messages from popping up - part 2

Ok, I got another one. I click on a button and it runs this code:

Private Sub cmdEnterScores_Click()
ChDir "C:\WINDOWS"
Workbooks.Open FileName:="C:\WINDOWS\datasheet2006.xls"
(more non-important code here)

If the datasheet2006.xls does not exist I get a VB error telling me so and
the script halts. How do I code it so that if the datasheet.xls does not
exist I can pop up my own msgbox instead of the vb script error box?

Thanks,
Phil
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Stopping error messages from popping up - part 2

First, I wouldn't put any of my files in the C:\windows folder. That folder is
made for system stuff. And there's too much of a chance that I may "clean up"
too much when I clean up my stuff.


dim TestStr as string
dim myFileName as string

myfilename = "C:\windows\datasheet2006.xls"

teststr = ""
on error resume next
teststr = dir(myfilename)
on error goto 0

if teststr = "" then
msgbox "Not found"
else
msgbox "Found it"
end if



phil-rge-ee wrote:

Ok, I got another one. I click on a button and it runs this code:

Private Sub cmdEnterScores_Click()
ChDir "C:\WINDOWS"
Workbooks.Open FileName:="C:\WINDOWS\datasheet2006.xls"
(more non-important code here)

If the datasheet2006.xls does not exist I get a VB error telling me so and
the script halts. How do I code it so that if the datasheet.xls does not
exist I can pop up my own msgbox instead of the vb script error box?

Thanks,
Phil


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Stopping error messages from popping up - part 2

I put it in the windows folder so it could be somewhat hidden so people
"cleaning up" their computers wouldn't see it and delete it, thinking they
wouldn't dare delete something from the windows folder, but alas, some still
see this file, think they don't need it and delete it. I'm thinking of moving
it to another location, but I also want to have this popup come up if the
file does get deleted "by accident".

Thanks for the help.
Phil

"Dave Peterson" wrote:

First, I wouldn't put any of my files in the C:\windows folder. That folder is
made for system stuff. And there's too much of a chance that I may "clean up"
too much when I clean up my stuff.


dim TestStr as string
dim myFileName as string

myfilename = "C:\windows\datasheet2006.xls"

teststr = ""
on error resume next
teststr = dir(myfilename)
on error goto 0

if teststr = "" then
msgbox "Not found"
else
msgbox "Found it"
end if



phil-rge-ee wrote:

Ok, I got another one. I click on a button and it runs this code:

Private Sub cmdEnterScores_Click()
ChDir "C:\WINDOWS"
Workbooks.Open FileName:="C:\WINDOWS\datasheet2006.xls"
(more non-important code here)

If the datasheet2006.xls does not exist I get a VB error telling me so and
the script halts. How do I code it so that if the datasheet.xls does not
exist I can pop up my own msgbox instead of the vb script error box?

Thanks,
Phil


--

Dave Peterson

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
Stopping Auto calculation in Part of a Worksheet Mhukki Excel Worksheet Functions 1 April 30th 08 05:04 PM
Stopping "Query Refresh" messages fmistry Excel Discussion (Misc queries) 2 March 6th 07 03:38 PM
Stopping "Query Refresh" messages fmistry Excel Discussion (Misc queries) 0 February 27th 07 08:33 PM
Stopping windows installer from popping up all the time Steve Excel Discussion (Misc queries) 0 January 19th 06 12:22 PM
All macros failing part way through with different error messages magpie Excel Discussion (Misc queries) 2 March 24th 05 02:31 PM


All times are GMT +1. The time now is 10:45 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"