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:
  1. Private Sub Workbook_Open()
  2. On Error Resume Next
  3. Workbooks(ThisWorkbook.Path & "\heatfinderold.xls").Close
  4. On Error Resume Next
  5. Kill (ThisWorkbook.Path & "\heatfinderold.xls")
  6. UserForm1.Show
  7. Heat.Show
  8. Run "macro2"
  9. End Sub

Macro2 Code:
  1. Private Sub macro2()
  2. Application.AutomationSecurity = msoAutomationSecurityLow
  3.     'Microsoft Scripting Runtime
  4.     Dim fso As New FileSystemObject
  5.     Dim wFile As File    'Handle for fso 'File' Object
  6.     Dim wPath As String
  7.     Dim wName As String
  8.     Dim cwb
  9.    
  10.     'File name's and path
  11.     wPath = "H:\"
  12.     wName = "heatfinder2.xls"
  13.    
  14.     If fso.FileExists(wPath & wName) Then
  15.         Set wFile = fso.GetFile(wPath & wName)     'Setting Handle
  16.     End If
  17.    
  18.     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
  19.     Application.DisplayAlerts = False
  20.     If Updater = vbYes Then ThisWorkbook.SaveAs ThisWorkbook.Path & "\heatfinderold.xls" Else Exit Sub
  21.     If Updater = vbYes Then FileCopy "H:\heatfinder2.xls", ThisWorkbook.Path & "\heatfinder2.xls" Else Exit Sub
  22.    
  23.    
  24.      'Clean House
  25.     Set wFile = Nothing
  26.     Workbooks.Open (ThisWorkbook.Path & "\heatfinder2.xls")
  27.     Application.DisplayAlerts = True
  28. 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