+ Reply to Thread
Results 1 to 2 of 2

How to prevent a 'copy' from opening

  1. #1
    phil
    Guest

    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. #2
    Charles Harmon
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    >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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1