Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Open Excel Book

  1. #1
    Board Regular
    Join Date
    Mar 2002
    Location
    Arkansas
    Posts
    358
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi all. I am trying to open a excel workbook with a cdm button. The workbook is named Exlabor.xls,and dont know if it maters but is in a subdirectory of the workbook with the cmd. This is what I have do I nead any thing else with it ?

    Private Sub CdmElabor_Click()
    Workbooks.Open Filename:="exlabor.xls"
    Sheets("sheet1").Select
    End Sub

  2. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Christchurch New Zealand
    Posts
    1,030
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    try

    ChDir "W:Directory"

    Workbooks.Open filename:="W:BuyersManFilesexlabor.xls"

    there is only one backslash though don't know why it puts in 2
    where w: is the drive

    [ This Message was edited by: brettvba on 2002-04-02 18:56 ]

    [ This Message was edited by: brettvba on 2002-04-02 18:57 ]

    [ This Message was edited by: brettvba on 2002-04-02 18:58 ]

  3. #3
    Board Regular
    Join Date
    Mar 2002
    Location
    Arkansas
    Posts
    358
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Ok will try Brett thx. If in the same directory code is fine, but in different Im having trouble. Thanks again Dan

  4. #4
    MrExcel MVP Ivan F Moala's Avatar
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    4,209
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-04-02 19:00, dantb wrote:
    Ok will try Brett thx. If in the same directory code is fine, but in different Im having trouble. Thanks again Dan
    As well as what Brett suggested....
    Just put the the full file path and file name
    in your open call routine


    Kind Regards,
    Ivan F Moala From the City of Sails

  5. #5
    Board Regular
    Join Date
    Mar 2002
    Location
    Arkansas
    Posts
    358
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thanks Again for your Help It works Great. In case these files are put into anouther directory Like C:/Program Files/ (or what ever the user Picks), is there anyway of leaving the Whole path out ? This is what I have.

    Private Sub CdmElabor_Click()
    FrmLbedit.Hide
    ChDir "C:Unit PriceDocuments"
    Workbooks.Open Filename:="C:Unit PriceDocumentsexlabor.xls"
    Sheets("sheet1").Select
    End Sub

  6. #6
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    If you find a way to store what the user picks, whether it's a cell entry or an input box. It may behoove you to elaborate as to how the user chooses their target directory.

  7. #7
    Board Regular
    Join Date
    Mar 2002
    Location
    Arkansas
    Posts
    358
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    not a cell or pick. When someone Actualy installs the program, they have a choice of my default directory or choising there own. And if they choise there own, I dont think the code will work.

  8. #8
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Depends how they choose their's, if it's a global variable, you may be able to refer to it in your code. Do they choose via Excel or Windows (e.g., Add/Remove Programs)?

    _________________
    Cheers, NateO

    [ This Message was edited by: NateO on 2002-04-02 19:59 ]

  9. #9
    Board Regular
    Join Date
    Mar 2002
    Location
    Arkansas
    Posts
    358
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I have a simple installer program, I have no dll's, or special system files, just a directory with 6 sub directories. Just trying to make it easy to install with out using copy/Paste.

  10. #10
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I have to apologize, I still don't know contextually as to how I best answer. You could do a file search on a drive, but multiples could prove to be a challenge. You could also have the user browse for the file using:

    Code:
    Dim myFl As Variant
    myFl = Application.GetOpenFilename("Excel-files,*.xls", 1, "Select Yer File", , False)
    myFl will hold the filepath & filename (i.e., Workbooks.Open filename:=myFl)


    _________________
    Cheers, NateO

    [ This Message was edited by: NateO on 2002-04-02 20:23 ]

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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