Export code not working in new version

I

Irshad Alam

I have a .mdb which I made on Windows XP and MS office 2000. The following
code is working fine:

Function ExpoXLS()
Dim rptCurrentReport As Report
Set rptCurrentReport = Screen.ActiveReport
DoCmd.OutputTo acOutputReport, rptCurrentReport.Name,
"MicrosoftExcel(*.xls)", "C:\" & rptCurrentReport.Name & Date & ".xls", True,
""""
End Function

The same mdb I am using on Windows Vista and Ms Office 2003, its producing
error for the above code.

I could not understand, whats the problem. Please suggest me.

Regards.

Irshad
 
R

Ron Weiner

Vista Security is undoubtedly not allowing you to write the file in the root
directory of the C: drive. Hard coding an output file location as you are
doing here was bound to fail sooner or later. The answer is to create the
file in a place that the user has write privileges. There has been lots of
discussion about this and other Vista related security changes. You will
need to do a little reading on the subject.

As an aside you really ought to have an error handler in a routine like
this, where it wants to create a file. I also do not understand why it is a
Function. I do not see it either declaring a return type or returning a
value.

Ron W
 
I

Irshad Alam

Sir,

Actually I am not very good in VBA coding. I just manage to write it anyhow,
therefore I could not write the error handling codes.

Reason for using this in function is that I am using this function in the
toolbar. This tool bar is shown in the report, if user wants to export is to
excel, he clicks and the current screen report is exported to excel. It was
working fine in Windows XP and office 2000.

Please suggest any alternate way to handle this situation, as it is required
badly.

Regards

Irshad
 

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