+ Reply to Thread
Results 1 to 7 of 7

Search and open feature

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-06-2006
    Posts
    108

    Search and open feature

    The pictures speak for themselves:

    \1

    \1

    I already tried to fix this using the following macro but no success

    Sub OpenWorkbook()
    Dim s1 as String, bk as Workbook, bk1 as Workbook
    s1 = "C:\Documents and Settings\" & _
    "fackt0\Desktop\Shipments\"
    
    set bk = activeWorkbook
    if dir(s1 & Range("C3").Text & ".xls") <> "" then
    set bk1 = Workbooks.Open(s1 & Range("J5").Text & ".xls")
    bk.Activate
    else
    msgbox "workbook not found"
    End if
    End sub
    Anyone with an idea what might be wrong?
    Last edited by TomBP; 07-07-2006 at 04:59 AM.

  2. #2
    NickHK
    Guest

    Re: Search and open feature

    Tom,
    Well which error are you getting ?
    Also what is the value of Range("C3").Text, as there is no obvious value
    from your jpg.

    NickHK

    "TomBP" <[email protected]> wrote in
    message news:[email protected]...
    >
    > The pictures speak for themselves:
    >
    > [image: http://i54.photobucket.com/albums/g1...BP/Pic1-4.jpg]
    >
    > [image: http://i54.photobucket.com/albums/g1...BP/Pic2-3.jpg]
    >
    > I already tried to fix this using the following macro but no success
    >
    >
    > Code:
    > --------------------
    > Sub OpenWorkbook()
    > Dim s1 as String, bk as Workbook, bk1 as Workbook
    > s1 = "C:\Documents and Settings\" & _
    > "fackt0\Desktop\Shipments\"
    >
    > set bk = activeWorkbook
    > if dir(s1 & Range("C3").Text & ".xls") <> "" then
    > set bk1 = Workbooks.Open(s1 & Range("J5").Text & ".xls")
    > bk.Activate
    > else
    > msgbox "workbook not found"
    > End if
    > End sub
    > --------------------
    >
    >
    > Anyone with an idea what might be wrong?
    >
    >
    > --
    > TomBP
    > ------------------------------------------------------------------------
    > TomBP's Profile:

    http://www.excelforum.com/member.php...o&userid=36112
    > View this thread: http://www.excelforum.com/showthread...hreadid=559237
    >




  3. #3
    Forum Contributor
    Join Date
    07-06-2006
    Posts
    108
    Nick

    It gives the following error

    \1

    The C3 range was wrong. It should be J5. I adjusted this but that doesn't seem to do the trick.

  4. #4
    NickHK
    Guest

    Re: Search and open feature

    Tom,
    Look at the code:
    Sub Macro1()
    'Comments.....
    Sub OpenWorkbook()

    You have no "End Sub" for Macro1.

    NickHK

    "TomBP" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Nick
    >
    > It gives the following error
    >
    > [image: http://i54.photobucket.com/albums/g115/TomBP/Error.jpg]
    >
    > The C3 range was wrong. It should be J5. I adjusted this but that
    > doesn't seem to do the trick.
    >
    >
    > --
    > TomBP
    > ------------------------------------------------------------------------
    > TomBP's Profile:

    http://www.excelforum.com/member.php...o&userid=36112
    > View this thread: http://www.excelforum.com/showthread...hreadid=559237
    >




  5. #5
    Forum Contributor
    Join Date
    07-06-2006
    Posts
    108
    This is another macro I use for another sheet. This works fine and I see no difference in standard lines with the macro which isn't working

    Sub Macro2()
    '
    ' Macro2 Macro
    ' Macro recorded 4/07/2006 by BPPassPort User
    '
    ' Keyboard Shortcut: Ctrl+t
    '
    Dim s As String, s1 As String
    s = ActiveSheet.Range("F10").Text
    s1 = "C:\Documents and Settings\" & _
    "fackt0\Desktop\Excel probleem\Shipments\"
    ActiveWorkbook.SaveAs _
    Filename:=s1 & s & ".xls", _
    FileFormat:=xlNormal, _
    Password:="", _
    WriteResPassword:="", _
    ReadOnlyRecommended:=False, _
    CreateBackup:=False
    End Sub

    This is the macro which isn't working again.

    Sub Macro1()
    '
    ' Macro1 Macro
    ' Macro recorded 4/07/2006 by BPPassPort User
    '
    ' Keyboard Shortcut: Ctrl+t
    '
    
    Sub OpenWorkbook()
    Dim s1 as String, bk as Workbook, bk1 as Workbook
    s1 = "C:\Documents and Settings\" & _
    "fackt0\Desktop\Shipments\"
    
    set bk = activeWorkbook
    if dir(s1 & Range("C3").Text & ".xls") <> "" then
    set bk1 = Workbooks.Open(s1 & Range("J5").Text & ".xls")
    bk.Activate
    else
    msgbox "workbook not found"
    End if
    End sub

  6. #6
    NickHK
    Guest

    Re: Search and open feature

    Tom,
    Yes, look:
    > Sub Macro1() <<<<<<<<< 1 sub
    > '
    > ' Macro1 Macro
    > ' Macro recorded 4/07/2006 by BPPassPort User
    > '
    > ' Keyboard Shortcut: Ctrl+t
    > '
    >
    > Sub OpenWorkbook() <<<<<<<<< 2 sub


    NickHK

    "TomBP" <[email protected]> wrote in
    message news:[email protected]...
    >
    > This is another macro I use for another sheet. This works fine and I see
    > no difference in standard lines with the macro which isn't working
    >
    >
    > Code:
    > --------------------
    > Sub Macro2()
    > '
    > ' Macro2 Macro
    > ' Macro recorded 4/07/2006 by BPPassPort User
    > '
    > ' Keyboard Shortcut: Ctrl+t
    > '
    > Dim s As String, s1 As String
    > s = ActiveSheet.Range("F10").Text
    > s1 = "C:\Documents and Settings\" & _
    > "fackt0\Desktop\Excel probleem\Shipments\"
    > ActiveWorkbook.SaveAs _
    > Filename:=s1 & s & ".xls", _
    > FileFormat:=xlNormal, _
    > Password:="", _
    > WriteResPassword:="", _
    > ReadOnlyRecommended:=False, _
    > CreateBackup:=False
    > End Sub
    > --------------------
    >
    >
    >
    > This is the macro which isn't working again.
    >
    >
    > Code:
    > --------------------
    > Sub Macro1()
    > '
    > ' Macro1 Macro
    > ' Macro recorded 4/07/2006 by BPPassPort User
    > '
    > ' Keyboard Shortcut: Ctrl+t
    > '
    >
    > Sub OpenWorkbook()
    > Dim s1 as String, bk as Workbook, bk1 as Workbook
    > s1 = "C:\Documents and Settings\" & _
    > "fackt0\Desktop\Shipments\"
    >
    > set bk = activeWorkbook
    > if dir(s1 & Range("C3").Text & ".xls") <> "" then
    > set bk1 = Workbooks.Open(s1 & Range("J5").Text & ".xls")
    > bk.Activate
    > else
    > msgbox "workbook not found"
    > End if
    > End sub
    > --------------------
    >
    >
    > --
    > TomBP
    > ------------------------------------------------------------------------
    > TomBP's Profile:

    http://www.excelforum.com/member.php...o&userid=36112
    > View this thread: http://www.excelforum.com/showthread...hreadid=559237
    >




+ 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