Open excel file

S

Sangeetha

Hi,

I want to open excel file using a commnad button placed in a form. I have
read the other questions to this to use runapplication. But, what I am
looking for is as follows:

i have tax database which contain the taxpayer name, taxyear and the Taxid
number. I have placed this table in a form. The tax caluclations are made in
excel and stored in a particular folder say named, Tax_comp and with
filenames Taxpayer_year.xlsx. I want to place a command button on the form,
and when the user clicks the command button, i want the particular tax payer
excel tax computation file stored in the folder to open. Is this possible.

Also, I take this oppurtunity to apologize for not responding to those, who
have responded to my earlier query on creating autonumber based on
conditions. It worked. Many thanks. I had a problem in replying. Whenever i
tried, it came out of the browser and it gets hanged up in the hotmail.
 
D

Douglas J. Steele

Assuming all you want is to open the file, you can use FollowHyperlink

Dim strFile As String

strFile = "C:\Tax_comp\" & strTaxpayer & "_" & lngYear & ".xlsx"
If Len(Dir(strFile)) > 0 Then
Application.FollowHyperlink strFile
Else
MsgBox strFile & " does not exist."
End If
 
S

Sangeetha

Thanks for your quick response.

But, i am afraid, it is not working. Please let me know what is the format
you have assumed for year.

I created two excel files (the 2007 version is a trial version which I am
using at present) named maran_2009 and sangeetha _2008 and saved it in the
folder C:\tax_comp.

The records are tax_payer_id (Autonumber) - 1, TaxPayer (Text)-
Sangeetha,tax_year(date)-30/06/2008. and the other record simliar 2, Maran,
30/06/2009.

It always executes the else command and says file foes not exists. please
help.
 
D

Douglas J. Steele

I'm assuming that strFile will contain the full path to the file to be
opened.

Sorry, I thought that was obvious...
 
S

Sangeetha

Oh! Thanks. I got it.

Douglas J. Steele said:
I'm assuming that strFile will contain the full path to the file to be
opened.

Sorry, I thought that was obvious...

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)





.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top