PDA

View Full Version : [SOLVED] Save excel in temp



kunguito
04-30-2008, 02:03 AM
Q?estion at the end. You might want to skip explanation.

At a certain point in my Access project it prints an Excel file.
To avoid coding the format it opens an already existing Excel file as follows:

Set ex = New Excel.Application
'Opens a template
Set wb = ex.Workbooks.Open("C:\APLI\TEMPLATES\PIH.xls")
'Assignement of a Sheet object reference to the variable ws
Set ws = wb.Sheets("Sheet1")

Excel is made visible:
ex.Visible = True
'Only XL 97 supports UserControl Property
ex.UserControl = True

Then I do some changes on it and finally it's saved.
If Val(ex.Version) < 12 Then
'Only choice in the "Save as type" dropdown is Excel files(xls)
'because the Excel version is 2000-2003
fname = ex.GetSaveAsFilename(InitialFileName:=txtFileName, _
filefilter:="Excel Files (*.xls), *.xls", _
Title:="Save the inventory")
If fname <> False Then
'We use the 2000-2003 format xlWorkbookNormal here to save as xls
SourceWb.SaveAs fname, FileFormat:=-4143, CreateBackup:=False
End If
Else

Now the question: I don't want the user to be able to change the original file. Can I save first the document in some kind of temporary folder so that, if he attemts to modify anything, it doesn't affect the original file?

In other words I want to restrict access to the orinal file i get the format from.

Another possibility might be the use of merge procedure.

Thanks a lot!

Bob Phillips
04-30-2008, 02:19 AM
Change its attribute to read-only.