Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Stop Error 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

Your help is much needed and appreciated


--
phil in da uk
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 509
Default Stop Error Message

are you trying to open the workbook programmatically or is it a user chosen
opening? it sounds like you are trying programmatically. If that is the case
you could always make sure Excel chooses the correct workbook. If not try
on error resume next
statement


"phil" wrote:

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

Your help is much needed and appreciated


--
phil in da uk

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Stop Error Message

I am trying to control how the workbook is opened programatically
but I'm not sure how the 'on error resume next' is supposed to work
...where would I insert this in the code below? Thanks.

"ben" wrote:

are you trying to open the workbook programmatically or is it a user chosen
opening? it sounds like you are trying programmatically. If that is the case
you could always make sure Excel chooses the correct workbook. If not try
on error resume next
statement


"phil" wrote:

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

Your help is much needed and appreciated


--
phil in da uk

  #4   Report Post  
Posted to microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 509
Default Stop Error Message

anywhere would be acceptable
but if you are trying to open it programmatically, why would the workbook be
the wrong name or in the wrong directory as you can control exactly what is
opened?


"phil" wrote:

I am trying to control how the workbook is opened programatically
but I'm not sure how the 'on error resume next' is supposed to work
..where would I insert this in the code below? Thanks.

"ben" wrote:

are you trying to open the workbook programmatically or is it a user chosen
opening? it sounds like you are trying programmatically. If that is the case
you could always make sure Excel chooses the correct workbook. If not try
on error resume next
statement


"phil" wrote:

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

Your help is much needed and appreciated


--
phil in da uk

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Stop Error Message

sorry ben, its users opening the workbook, -I meant, I'm trying to use code
to determine how it is opened.

"ben" wrote:

anywhere would be acceptable
but if you are trying to open it programmatically, why would the workbook be
the wrong name or in the wrong directory as you can control exactly what is
opened?


"phil" wrote:

I am trying to control how the workbook is opened programatically
but I'm not sure how the 'on error resume next' is supposed to work
..where would I insert this in the code below? Thanks.

"ben" wrote:

are you trying to open the workbook programmatically or is it a user chosen
opening? it sounds like you are trying programmatically. If that is the case
you could always make sure Excel chooses the correct workbook. If not try
on error resume next
statement


"phil" wrote:

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

Your help is much needed and appreciated


--
phil in da uk



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Stop Error Message

The suggestion to enter 'On Error Resume Next' is not making any difference
Error 1004 pops up, saying it can't find TMR and then it opens the workbook
for full use.


"phil" wrote:

sorry ben, its users opening the workbook, -I meant, I'm trying to use code
to determine how it is opened.

"ben" wrote:

anywhere would be acceptable
but if you are trying to open it programmatically, why would the workbook be
the wrong name or in the wrong directory as you can control exactly what is
opened?


"phil" wrote:

I am trying to control how the workbook is opened programatically
but I'm not sure how the 'on error resume next' is supposed to work
..where would I insert this in the code below? Thanks.

"ben" wrote:

are you trying to open the workbook programmatically or is it a user chosen
opening? it sounds like you are trying programmatically. If that is the case
you could always make sure Excel chooses the correct workbook. If not try
on error resume next
statement


"phil" wrote:

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

Your help is much needed and appreciated


--
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
#NAME? - is there a way to stop this error message? m@cr0 Excel Discussion (Misc queries) 3 July 23rd 08 03:17 PM
How to stop a recurrent circular reference error message ? DaveWB3DWE Excel Discussion (Misc queries) 1 August 10th 07 05:10 PM
Stop error message Oggy Excel Discussion (Misc queries) 0 April 15th 07 04:26 PM
stop error message phil Excel Programming 0 January 22nd 05 03:31 PM
stop error message phil Excel Programming 4 January 22nd 05 03:27 PM


All times are GMT +1. The time now is 06:10 PM.

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"