View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Open window - on error

Hi AL007,

Try:

'=============
Sub Opendefactivewkbk()
Dim FName

If ActiveWorkbook.Path < vbNullString Then
ChDrive ActiveWorkbook.Path
ChDir ActiveWorkbook.Path
Else
ChDrive "D"
End If

FName = Application.GetOpenFilename()
If FName < False Then Workbooks.Open FName

End Sub
'<<=============


---
Regards,
Norman


"al007" wrote in message
oups.com...
Sub Opendefactivewkbk()
On Error GoTo ErrorTrap1
ChDrive ActiveWorkbook.Path
ChDir ActiveWorkbook.Path
FName = Application.GetOpenFilename()
ErrorTrap1:
ChDrive "D"
FName = Application.GetOpenFilename()
If FName < False Then Workbooks.Open FName

End Sub

The above macro works well without the on error - however i need it in
case i want to open a file from an active workbook which has not yet
been saved.
My problem is that I have 2 open window appearing one after the other
if there is no error.
an anybody correct my code pls
thxs