Hello again been a while since I've posted, but been a little busy with things (kid should be ready to pop out in a few months :)) Created a little script to update a program I created for work but it just does not run the way I want it to thought I would post it to see if anyone can tell me what I'm doing wrong.
The code btw does almost completely work the only part it gets stuck on is closing the previous workbook and then deleting it.
Here it is:
On Workbook Open Code:
Private Sub Workbook_Open() On Error Resume Next Workbooks(ThisWorkbook.Path & "\heatfinderold.xls").Close On Error Resume Next Kill (ThisWorkbook.Path & "\heatfinderold.xls") UserForm1.Show Heat.Show Run "macro2" End Sub
Macro2 Code:
Private Sub macro2() Application.AutomationSecurity = msoAutomationSecurityLow 'Microsoft Scripting Runtime Dim fso As New FileSystemObject Dim wFile As File 'Handle for fso 'File' Object Dim wPath As String Dim wName As String Dim cwb 'File name's and path wPath = "H:\" wName = "heatfinder2.xls" If fso.FileExists(wPath & wName) Then Set wFile = fso.GetFile(wPath & wName) 'Setting Handle End If If wFile.DateCreated > ThisWorkbook.BuiltinDocumentProperties("Creation Date") Then Updater = MsgBox("There is an update available for this application would you like to download it?", vbYesNo, "Update Found") Else Exit Sub Application.DisplayAlerts = False If Updater = vbYes Then ThisWorkbook.SaveAs ThisWorkbook.Path & "\heatfinderold.xls" Else Exit Sub If Updater = vbYes Then FileCopy "H:\heatfinder2.xls", ThisWorkbook.Path & "\heatfinder2.xls" Else Exit Sub 'Clean House Set wFile = Nothing Workbooks.Open (ThisWorkbook.Path & "\heatfinder2.xls") Application.DisplayAlerts = True End Sub
Also does anyone know a better way to find the path of the document besides ThisWorkbook.Path Ive found that it does not work if the document is in the users My Documents folder in which it just saves in the folder above.
Thanks again for any ideas :)
