The object of the macro is to open workbooks in one folder, "save as" into a new folder, apply the data values to a scorecard workbook and then delete the original workbook in the first folder. If I run the macro in the VBA Edit window, all goes well and the second folder contains all the workbook from the first folder and all the data is updated on the scorecard workbook. If I execute the macro from a shortcut key module the code "Stalls " on the first Workbooks.Open statement. The workbook opens and then no code is executed.
Private Sub TestPaste()
MyPath1 = "C:\Documents and Settings\browns\Desktop\Scratch1\"
MyPath2 = "C:\Documents and Settings\browns\Desktop\Scratch2\"
ScorecardName = "PasteTest Scorecard.xls"
Myname = Dir(MyPath1 + "*.xls") ' Retrieve the first entry.
Do While Myname <> "" ' Start the loop.
' Ignore the current directory and the encompassing directory.
If Myname <> "." And Myname <> ".." Then
strVar = MyPath1 + Myname
Workbooks.Open Filename:=strVar
strVar = MyPath2 + Myname
Workbooks(Myname).Activate
ChDir MyPath2
ActiveWorkbook.SaveAs _
Filename:=strVar, _
FileFormat:= _
xlNormal, Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
Workbooks(ScorecardName).Activate
strAns = Update_Paste_Values()
strVar = MyPath1 + Myname
Kill strVar
End If
Myname = Dir ' Get next entry.
Loop
End Sub
Bookmarks