+ Reply to Thread
Results 1 to 5 of 5

Window Message for not value found

Hybrid View

  1. #1
    maperalia
    Guest

    Window Message for not value found

    I have a program that open an excel file from select cell by asking the work
    order number (see below). What statement do I need to get a window message
    when I type the wrong work order number?.

    Thanks in advance.
    Maperalia


    Sub Open_xls_File()

    WO = Application.InputBox("Enter Work Order Number")
    directory = "C:\Test\Colors\" & WO & "\"
    filetext = Selection.Value
    Workbooks.Open directory & filetext

    End Sub


  2. #2
    Ron de Bruin
    Guest

    Re: Window Message for not value found

    Try this

    If Dir(directory & filetext & ".xls") <> "" Then
    Workbooks.Open directory & filetext & ".xls"
    Else
    MsgBox "Wrong"
    End If


    Maybe without the .xls part ?


    --
    Regards Ron de Bruin
    http://www.rondebruin.nl


    "maperalia" <[email protected]> wrote in message news:[email protected]...
    >I have a program that open an excel file from select cell by asking the work
    > order number (see below). What statement do I need to get a window message
    > when I type the wrong work order number?.
    >
    > Thanks in advance.
    > Maperalia
    >
    >
    > Sub Open_xls_File()
    >
    > WO = Application.InputBox("Enter Work Order Number")
    > directory = "C:\Test\Colors\" & WO & "\"
    > filetext = Selection.Value
    > Workbooks.Open directory & filetext
    >
    > End Sub
    >




  3. #3
    maperalia
    Guest

    Re: Window Message for not value found

    Ron;
    Thanks for your quick response.
    I statement is running very well, however, I donot wher I have to located
    into my program because I got the window message all the time.
    Could you please tell me where can I located it into my program?

    Thanks.\
    Maparalia


    "Ron de Bruin" wrote:

    > Try this
    >
    > If Dir(directory & filetext & ".xls") <> "" Then
    > Workbooks.Open directory & filetext & ".xls"
    > Else
    > MsgBox "Wrong"
    > End If
    >
    >
    > Maybe without the .xls part ?
    >
    >
    > --
    > Regards Ron de Bruin
    > http://www.rondebruin.nl
    >
    >
    > "maperalia" <[email protected]> wrote in message news:[email protected]...
    > >I have a program that open an excel file from select cell by asking the work
    > > order number (see below). What statement do I need to get a window message
    > > when I type the wrong work order number?.
    > >
    > > Thanks in advance.
    > > Maperalia
    > >
    > >
    > > Sub Open_xls_File()
    > >
    > > WO = Application.InputBox("Enter Work Order Number")
    > > directory = "C:\Test\Colors\" & WO & "\"
    > > filetext = Selection.Value
    > > Workbooks.Open directory & filetext
    > >
    > > End Sub
    > >

    >
    >
    >


  4. #4
    Ron de Bruin
    Guest

    Re: Window Message for not value found

    If you have filename.xls in the worksheet cell then use example 2.
    If you only have the filename without the extension use example1


    Sub Open_xls_File1()

    WO = Application.InputBox("Enter Work Order Number")
    directory = "C:\Test\Colors\" & WO & "\"
    filetext = Selection.Value

    If Dir(directory & filetext & ".xls") <> "" Then
    Workbooks.Open directory & filetext & ".xls"
    Else
    MsgBox "Wrong"
    End If

    End Sub


    Sub Open_xls_File2()

    WO = Application.InputBox("Enter Work Order Number")
    directory = "C:\Test\Colors\" & WO & "\"
    filetext = Selection.Value

    If Dir(directory & filetext) <> "" Then
    Workbooks.Open directory & filetext
    Else
    MsgBox "Wrong"
    End If

    End Sub

    --
    Regards Ron de Bruin
    http://www.rondebruin.nl


    "maperalia" <[email protected]> wrote in message news:[email protected]...
    > Ron;
    > Thanks for your quick response.
    > I statement is running very well, however, I donot wher I have to located
    > into my program because I got the window message all the time.
    > Could you please tell me where can I located it into my program?
    >
    > Thanks.\
    > Maparalia
    >
    >
    > "Ron de Bruin" wrote:
    >
    >> Try this
    >>
    >> If Dir(directory & filetext & ".xls") <> "" Then
    >> Workbooks.Open directory & filetext & ".xls"
    >> Else
    >> MsgBox "Wrong"
    >> End If
    >>
    >>
    >> Maybe without the .xls part ?
    >>
    >>
    >> --
    >> Regards Ron de Bruin
    >> http://www.rondebruin.nl
    >>
    >>
    >> "maperalia" <[email protected]> wrote in message news:[email protected]...
    >> >I have a program that open an excel file from select cell by asking the work
    >> > order number (see below). What statement do I need to get a window message
    >> > when I type the wrong work order number?.
    >> >
    >> > Thanks in advance.
    >> > Maperalia
    >> >
    >> >
    >> > Sub Open_xls_File()
    >> >
    >> > WO = Application.InputBox("Enter Work Order Number")
    >> > directory = "C:\Test\Colors\" & WO & "\"
    >> > filetext = Selection.Value
    >> > Workbooks.Open directory & filetext
    >> >
    >> > End Sub
    >> >

    >>
    >>
    >>




  5. #5
    maperalia
    Guest

    Re: Window Message for not value found

    Thanks you very much Ron it is working PERFECTLY!!!!!.

    Best regards
    Maperalia

    "Ron de Bruin" wrote:

    > If you have filename.xls in the worksheet cell then use example 2.
    > If you only have the filename without the extension use example1
    >
    >
    > Sub Open_xls_File1()
    >
    > WO = Application.InputBox("Enter Work Order Number")
    > directory = "C:\Test\Colors\" & WO & "\"
    > filetext = Selection.Value
    >
    > If Dir(directory & filetext & ".xls") <> "" Then
    > Workbooks.Open directory & filetext & ".xls"
    > Else
    > MsgBox "Wrong"
    > End If
    >
    > End Sub
    >
    >
    > Sub Open_xls_File2()
    >
    > WO = Application.InputBox("Enter Work Order Number")
    > directory = "C:\Test\Colors\" & WO & "\"
    > filetext = Selection.Value
    >
    > If Dir(directory & filetext) <> "" Then
    > Workbooks.Open directory & filetext
    > Else
    > MsgBox "Wrong"
    > End If
    >
    > End Sub
    >
    > --
    > Regards Ron de Bruin
    > http://www.rondebruin.nl
    >
    >
    > "maperalia" <[email protected]> wrote in message news:[email protected]...
    > > Ron;
    > > Thanks for your quick response.
    > > I statement is running very well, however, I donot wher I have to located
    > > into my program because I got the window message all the time.
    > > Could you please tell me where can I located it into my program?
    > >
    > > Thanks.\
    > > Maparalia
    > >
    > >
    > > "Ron de Bruin" wrote:
    > >
    > >> Try this
    > >>
    > >> If Dir(directory & filetext & ".xls") <> "" Then
    > >> Workbooks.Open directory & filetext & ".xls"
    > >> Else
    > >> MsgBox "Wrong"
    > >> End If
    > >>
    > >>
    > >> Maybe without the .xls part ?
    > >>
    > >>
    > >> --
    > >> Regards Ron de Bruin
    > >> http://www.rondebruin.nl
    > >>
    > >>
    > >> "maperalia" <[email protected]> wrote in message news:[email protected]...
    > >> >I have a program that open an excel file from select cell by asking the work
    > >> > order number (see below). What statement do I need to get a window message
    > >> > when I type the wrong work order number?.
    > >> >
    > >> > Thanks in advance.
    > >> > Maperalia
    > >> >
    > >> >
    > >> > Sub Open_xls_File()
    > >> >
    > >> > WO = Application.InputBox("Enter Work Order Number")
    > >> > directory = "C:\Test\Colors\" & WO & "\"
    > >> > filetext = Selection.Value
    > >> > Workbooks.Open directory & filetext
    > >> >
    > >> > End Sub
    > >> >
    > >>
    > >>
    > >>

    >
    >
    >


+ 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