« Combine multiple workbooks into one: VBA Excel | Main | Browse for file and return path: VBA Excel »
Sunday
Jul152007

Check to see if file is open before opening: VBA Excel


Dim NewWB as workbook
Set NewWb = Workbooks(CStr(Month(Now) & " " & Day(Now) & " " & Year(Now)) & ".xls")

If NewWb Is Nothing Then
  Set NewWb = Workbooks.Add
      With NewWb
          .Title = CStr(DateValue(Now))
          .Subject = "MTB GL Statement"
          .SaveAs Filename:=CStr(Month(Now) & " " & Day(Now) & " " & Year(Now)) & ".xls"
          .SaveAs Filename:=Application.GetSaveAsFilename(fileFilter:="Excel Files (*.xls), *.xls")
      End With
End If

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
All HTML will be escaped. Textile formatting is allowed.