Open an Excel file from Access

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
Is it possible to open an excel file from access, I have spefic file to
open, can we give a command button for this.
 
AR said:
-----Original Message-----
Hi
Is it possible to open an excel file from access, I have spefic file to
open, can we give a command button for this.
.

Hi AR,

use the following as an example:

***** code starts *****

sub OpenExcel()
dim xlApp as object
dim xlBook as object
dim strFile as string

on error resume next
' reference an open session of excel
set xlApp=getobject(,"Excel.application")

if err.number<>0 then
' excel not currently open
set xlApp=new excel.application
end if

strFile="path\file.xls"

with xlApp
set xlBook=.open(strFile)
..visible=true
end with

***** code ends ******

for more help to code in excel I recommend posting to the
excel programming newsgroup

Luck
Jonathan
 
Back
Top