View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\) Rick Rothstein \(MVP - VB\) is offline
external usenet poster
 
Posts: 2,202
Default Fix code - check to see if a workbook is open, if so, save changes then close.

Describe "not working".

Rick


"J.W. Aldridge" wrote in message
ups.com...


Added the "If workbook...." command to code. Not working.

Any suggestions on how to fix this?

Sub Macro7()
'
' Macro7 Macro
' Macro recorded 10/9/2007 by JW'

'
Workbooks.Open Filename:="X:\FHI Share\pcp\jeremy\NEW PCP
DATA.xls", writerespassword:="pcp123"
ActiveWorkbook.RefreshAll
ActiveWorkbook.Close SaveChanges:=True

If Workbook.Open("X:\FHI Share\pcp\jeremy\PCP DATA UPDATE.xls")
Then
ActiveWorkbook.Close SaveChanges:=True
Workbooks("X:\FHI Share\pcp\jeremy\PCP DATA UPDATE.xls").Close


End If

End Sub