+ Reply to Thread
Results 1 to 4 of 4

Prevent Error Message

  1. #1
    phil
    Guest

    Prevent Error Message

    I have code written (see below) that makes sure if a workbook (TMR.xls)
    is called something else or is not located in the right folder (TMR folder),
    then the user cannot open it. 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

    Please note that simply entering 'On Error Resume Next' in the code is
    not making any difference. I need to prevent the Error dialogue kicking in.

    Your help is much needed and appreciated




    Expand AllCollapse All
    --
    phil in da uk

  2. #2
    Bob Phillips
    Guest

    Re: Prevent Error Message

    Where is the open code?

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "phil" <phil@discussions.microsoft.com> wrote in message
    news:9033153B-434A-4E19-9F15-422451576437@microsoft.com...
    > I have code written (see below) that makes sure if a workbook (TMR.xls)
    > is called something else or is not located in the right folder (TMR

    folder),
    > then the user cannot open it. 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
    >
    > Please note that simply entering 'On Error Resume Next' in the code is
    > not making any difference. I need to prevent the Error dialogue kicking

    in.
    >
    > Your help is much needed and appreciated
    >
    >
    >
    >
    > Expand AllCollapse All
    > --
    > phil in da uk




  3. #3
    phil
    Guest

    Re: Prevent Error Message

    Here is the full Open code:


    Private Sub Workbook_Open()
    Worksheets.Select
    Columns("A:M").Select
    ActiveWindow.Zoom = True
    ActiveSheet.ScrollArea = "A1:M30"
    Range("A1").Select
    Application.CommandBars.ActiveMenuBar.Enabled = False
    Application.DisplayFullScreen = True
    Application.CommandBars("Full Screen").Enabled = False
    Dim NumberofTBs As Integer
    Dim TBC As Integer
    Let NumberofTBs = Toolbars.Count
    For TBC = 1 To NumberofTBs
    Toolbars(TBC).Visible = False
    Next TBC
    For TBC = 2 To 18
    Application.CommandBars(TBC).Visible = False
    Application.DisplayStatusBar = False
    Application.DisplayFormulaBar = False
    Next TBC
    Application.Run "TMR.xls!Macro84"
    Application.Run "TMR.xls!Macro81"

    Sheets("MENU").Select
    On Error Resume Next
    If ActiveWorkbook.FullName <> "C:\TMR\TMR.xls" Or _
    Dir("C:\WINDOWS\system32\unicode.txt") = vbNullString Then
    MsgBox "Contact Psyfactor Ltd for Licence", vbOKOnly, "TMR"
    Application.ActiveWorkbook.Save
    Application.Quit
    Else
    Sheets("MENU").Select
    End If


    End Sub
    "Bob Phillips" wrote:

    > Where is the open code?
    >
    > --
    >
    > HTH
    >
    > RP
    > (remove nothere from the email address if mailing direct)
    >
    >
    > "phil" <phil@discussions.microsoft.com> wrote in message
    > news:9033153B-434A-4E19-9F15-422451576437@microsoft.com...
    > > I have code written (see below) that makes sure if a workbook (TMR.xls)
    > > is called something else or is not located in the right folder (TMR

    > folder),
    > > then the user cannot open it. 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
    > >
    > > Please note that simply entering 'On Error Resume Next' in the code is
    > > not making any difference. I need to prevent the Error dialogue kicking

    > in.
    > >
    > > Your help is much needed and appreciated
    > >
    > >
    > >
    > >
    > > Expand AllCollapse All
    > > --
    > > phil in da uk

    >
    >
    >


  4. #4
    Tom Ogilvy
    Guest

    Re: Prevent Error Message

    I assume the workbook being opened is supposed to be C:\TMR\TMR.xls

    if it isn't named TMR then these will raise that error

    Application.Run "TMR.xls!Macro84"
    Application.Run "TMR.xls!Macro81"


    this stops the code from running, but the workbook will continue to open.

    --
    Regards,
    Tom Ogilvy

    "phil" <phil@discussions.microsoft.com> wrote in message
    news:664ABD72-A8E1-4FD8-AA6C-6AB18CF9D4C0@microsoft.com...
    > Here is the full Open code:
    >
    >
    > Private Sub Workbook_Open()
    > Worksheets.Select
    > Columns("A:M").Select
    > ActiveWindow.Zoom = True
    > ActiveSheet.ScrollArea = "A1:M30"
    > Range("A1").Select
    > Application.CommandBars.ActiveMenuBar.Enabled = False
    > Application.DisplayFullScreen = True
    > Application.CommandBars("Full Screen").Enabled = False
    > Dim NumberofTBs As Integer
    > Dim TBC As Integer
    > Let NumberofTBs = Toolbars.Count
    > For TBC = 1 To NumberofTBs
    > Toolbars(TBC).Visible = False
    > Next TBC
    > For TBC = 2 To 18
    > Application.CommandBars(TBC).Visible = False
    > Application.DisplayStatusBar = False
    > Application.DisplayFormulaBar = False
    > Next TBC
    > Application.Run "TMR.xls!Macro84"
    > Application.Run "TMR.xls!Macro81"
    >
    > Sheets("MENU").Select
    > On Error Resume Next
    > If ActiveWorkbook.FullName <> "C:\TMR\TMR.xls" Or _
    > Dir("C:\WINDOWS\system32\unicode.txt") = vbNullString Then
    > MsgBox "Contact Psyfactor Ltd for Licence", vbOKOnly, "TMR"
    > Application.ActiveWorkbook.Save
    > Application.Quit
    > Else
    > Sheets("MENU").Select
    > End If
    >
    >
    > End Sub
    > "Bob Phillips" wrote:
    >
    > > Where is the open code?
    > >
    > > --
    > >
    > > HTH
    > >
    > > RP
    > > (remove nothere from the email address if mailing direct)
    > >
    > >
    > > "phil" <phil@discussions.microsoft.com> wrote in message
    > > news:9033153B-434A-4E19-9F15-422451576437@microsoft.com...
    > > > I have code written (see below) that makes sure if a workbook

    (TMR.xls)
    > > > is called something else or is not located in the right folder (TMR

    > > folder),
    > > > then the user cannot open it. 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
    > > >
    > > > Please note that simply entering 'On Error Resume Next' in the code is
    > > > not making any difference. I need to prevent the Error dialogue

    kicking
    > > in.
    > > >
    > > > Your help is much needed and appreciated
    > > >
    > > >
    > > >
    > > >
    > > > Expand AllCollapse All
    > > > --
    > > > 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