Modifying a Template from another Workbook

G

Guest

Thanks to help from this site, I was able to modify a Workbook from another
Workbook. Now I need to modify a Template from another Workbook. The
problem I have is that when the Template is opened, it is opened as a .xls
file with the number one following the Template name. This is expected
behavior but I need to open the template, modify it as a template, and save
it again with the same template name programatically. I cannot have the Save
As dialog box poping up. I need all this to happen by clicking a button and
no further user action.
Here is the code I use that causes the Save As box to pop up:

Set wb = Application.Workbooks.Open("C:\Templates\Test.xlt")
wb.Sheets("Sheet1").Select
wb.Sheets("Sheet1").Range("A4").Offset(-1, 0).Select
Selection.Insert Shift:=xlDown
Selection.Value = "New Comment 3"
wb.Close True
Set wb = Nothing
 
G

Guest

The only way that I have ever been able to open a file, change it and then
close it under a different name than the one shown in the title bar, is with
Save As. Then if I try to save it as a file name that already exists, it
will give me a message that asks if I want to overwrite the existing file. I
guess what I am saying is, I don't think you can do what you are trying to do
programmatically, unless you want to 1) Save the file as modified with the
dash number. 2) Programmatically delete the template file without the dash
3) Programmatically rename the dash number file to the template file name.
Even then, when the user pulls up the template and uses it, they will get a
SaveAs dialog box before closing unless they save it as the dash number.
 

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