Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2007
    Posts
    70

    Unanswered: Opening an excel file using an Access button?

    Hi,

    I would like to have a button on a form to open an Excel spreadsheet. I can make a button that opens a blank spreadsheet, but I'd like the button to open a specific excel spreadsheet.

    Any help would be great.

    Cheers,

    OB1

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    CHeck out the excel automation code in the codebank - it does that, as well as loads of other stuff.

  3. #3
    Join Date
    Dec 2007
    Posts
    70
    Hi,

    Sorry in advance if I'm just being blind but It all looked like it was creating a new .xls and copying data from the db into it. I want to open an .xls file that has nothing to do with the db?
    I did see something in one of the codes that might help:

    exApp.Workbooks.Open(BookName)

    If I put this into some vb could it work? How would I write the 'BookName'?

    Myexcel.xls or would I have to put the whole file path into it?

    bit confused

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Yes - some code creates a new file. Some opens files on the filesystem. ....Open does the latter.

    Why not look at what BookName is set to in the code?

  5. #5
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004

    Talking

    Quote Originally Posted by OB1
    Hi,

    I would like to have a button on a form to open an Excel spreadsheet. I can make a button that opens a blank spreadsheet, but I'd like the button to open a specific excel spreadsheet.

    Any help would be great.

    Cheers,

    OB1
    Hi,

    Not sure if this gets you exactly what you want but what I did in one of my databases is in DesignView, right click on the button, click on Properties. Then on the FormatTab click inside Hyperlink Address and just map it to where that form is. I'm sure there are more elaborate ways, but this got the sheet that I needed.

    have a nice one,
    BUD

  6. #6
    Join Date
    Dec 2007
    Posts
    70
    Hi,

    Cheers for your help yet again Pootle. Double checked the (BookName) in the code and cleared my hazy vision. I used:

    Code:
    Dim oApp As Object
        
    
        Set oApp = CreateObject("Excel.Application")
        oApp.Visible = True
        oApp.workbooks.Open ("C:\myexcelfile.xls")
    Worked fine


    And cheers Bud, I really should look more closely at the FormatTab before I jump in at the deep end!!

    Cheers
    OB1

Posting Permissions

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