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
Ron Weiner - 17 May 2008 15:53 GMT
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 have a .mdb which I made on Windows XP and MS office 2000. The following
> code is working fine:
[quoted text clipped - 16 lines]
>
> Irshad
Irshad Alam - 18 May 2008 09:31 GMT
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
> 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
[quoted text clipped - 29 lines]
> >
> > Irshad