Results 1 to 2 of 2

Thread: opening excel file in resources folder

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2012
    Posts
    16

    opening excel file in resources folder

    Excuse me, but how do you access a file (in my case excel) that is in the resources folder? I am using interop to access to all of my excel files, any ideas how to access them via the resources folder?

    Code:
    ' what i have:
    xlsWorkBook = xlsApp.Workbooks.Open("C:\inventario Programa Julio.xlsx")
    
    'is this right?
    xlsWorkBook = xlsApp.Workbooks.Open(Str(My.Resources.acceso))

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: opening excel file in resources folder

    are you adding the actual excel file as a resource, or a string that points to the excel file somewhere else on disk?

    If it is that you are adding the whole excel file, then it will be stored as a byte array inside your exe file. When you access it with My.Resources.acceso, you are getting an array of bytes, which you would need to write to disk (perhaps to the users temp folder) and then call workbooks.open() passing in the string path to the file on the drive. Excel is only going to open a file on disk, so you can't get around needing to extract it somewhere on the users drive. Look at My.Computer.FileSystem.WriteAllBytes() method, which would be useful to write the byte array of the file out to a place on the disk so you can open it.

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width