Creating a copy of excel file

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

Guest

Hi there,

Is there a way to make a copy of an original excel worksheet from access
using vba and then open that copy.

example: original excel c:\localdb\original.xls
 
If you mean workbook rather than worksheet, you can do something like
this:

Dim OriginalFile As String
Dim NewFile As String

OriginalFile = "c:\localdb\original.xls"
NewFile = "c:\localdb\new.xls"
FileCopy OriginalFile, Newfile
Application.FollowHyperlink NewFile

But consider turning original.xls into a .xlt template.
 
Hi John,

Thanks for your help..it worked out great. I have another issue that I
can't get to work. I want to make the excel file I've just copied print in a
report. I've inserted /linked the excel object in a report and removed the
source doc name. I'm trying to assign the name dynamically through a
variable and it keeps erroring out not allowing me to assign it on the fly.
Any ideas?
 
I've never tried embedding things in reports, so I'm guessing.

But if the report prints the way you expect when you've typed the
source document name into the properties sheet, but fails when you use
an expression there, I wonder if it could be that the expression is
being evaluated too late. You don't say how and when you're setting
the source document, but how about doing it in the Report's Open event
procedure?
 
Back
Top