PDA

View Full Version : Creating a template "Installer"



Shrout1
10-12-2004, 06:03 AM
I am hoping to create a macro that automatically places the file (or template file) currently open into the templates folder.

I know that the user can be prompted to perform a "Save As" but is there some way that, upon first execution of this file the user will be prompted with a window that says, "You need to install this file in order to use it" and then, if the user clicks "Ok" the file will make note of this action in an invisible sheet (thus changing the template itself) and save itself into the "Username/Application Data/Microsoft/Templates" folder?

This would just make it a lot easier on the user...

Thanks!

Jacob Hilderbrand
10-12-2004, 10:05 AM
Try something like this:

Dim Path As String
Dim FileName As String
Dim MyResponse As VbMsgBoxResult

Path = "Username/Application Data/Microsoft/Templates"
FileName = "MyName.xls"
If Sheets("Sheet1").Range("A1").Text = "Created" Then
'Do Something Here
Else
MyResponse = MsgBox("Do you want to install this program?", vbYesNo, "File Installation")
If MyResponse = vbYes Then
Sheets("Sheet1").Range("A1").Value = "Created"
ThisWorkbook.SaveAs FileName = Path & "\" & FileName
End If
End If