Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default How to prevent a 'copy' from opening

I have code written (see below) that makes sure if a workbook (TMR.xls)
is called something else or isnot located in the right folder (TMR folder),
then it will not open. It works fine if the workbook has been located in
another folder. But, if it has the wrong name and is in the TMR folder, a
Visual Basic Error message appears saying it can't locate the workbook, AND
THEN OPENS IT !!!! The visual basic error is preventing the rest of the code,
which would close the workbook.
any suggestions how to get around this? Your help will be appreciated.

code=

If ActiveWorkbook.FullName = "C:\TMR\TMR.xls" Then
Sheets("MENU").Select
Else
Sheets("End").Select
Application.ActiveWorkbook.Save
Application.Quit


--
phil in da uk
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default How to prevent a 'copy' from opening

Phil,
Try
On Error Resumn Next
If ActiveWorkbook.FullName = "C:\TMR\TMR.xls" Then
Sheets("MENU").Select
end if
If err = 1006 then
Application.ActiveWorkbook.Save
Application.Quit
end if

"phil" wrote in message
...
I have code written (see below) that makes sure if a workbook (TMR.xls)
is called something else or isnot located in the right folder (TMR
folder),
then it will not open. It works fine if the workbook has been located in
another folder. But, if it has the wrong name and is in the TMR folder, a
Visual Basic Error message appears saying it can't locate the workbook,
AND
THEN OPENS IT !!!! The visual basic error is preventing the rest of the
code,
which would close the workbook.
any suggestions how to get around this? Your help will be appreciated.

code=

If ActiveWorkbook.FullName = "C:\TMR\TMR.xls" Then
Sheets("MENU").Select
Else
Sheets("End").Select
Application.ActiveWorkbook.Save
Application.Quit


--
phil in da uk



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
prevent workbook opening if already open by someone else KevHardy Excel Discussion (Misc queries) 0 March 4th 10 10:02 AM
How to prevent any one from opening my workbook MMCM New Users to Excel 5 August 25th 06 07:54 PM
prevent second copy from opening Tom Ogilvy Excel Programming 0 July 10th 03 07:52 PM
prevent second copy from opening pancho[_2_] Excel Programming 0 July 10th 03 07:41 PM


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