ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Return to Original File (https://www.excelbanter.com/excel-programming/295919-return-original-file.html)

Stephen[_11_]

Return to Original File
 
Hi peoples

I need to make an adjustment to my code. If it opens the file DATA.xl
it needs to return to the original file (that was already open). Th
original file is different every month.

Dim wbk As Workbook
On Error Resume Next
Set wbk = Workbooks("DATA.xls")
On Error GoTo 0
If wbk Is Nothing Then
Workbooks.Open Filename:= _
"C:\DATA.xls"
Exit Sub
End If


Regards

Stephe

--
Message posted from http://www.ExcelForum.com


Frank Kabel

Return to Original File
 
Hi
try
Dim wbk As Workbook
Dim old_book as workbook
set old_book=activeworkbook
On Error Resume Next
Set wbk = Workbooks("DATA.xls")
On Error GoTo 0
If wbk Is Nothing Then
Workbooks.Open Filename:= _
"C:\DATA.xls"
old_book.activate
Exit Sub
End If


-----Original Message-----
Hi peoples

I need to make an adjustment to my code. If it opens the

file DATA.xls
it needs to return to the original file (that was already

open). The
original file is different every month.

Dim wbk As Workbook
On Error Resume Next
Set wbk = Workbooks("DATA.xls")
On Error GoTo 0
If wbk Is Nothing Then
Workbooks.Open Filename:= _
"C:\DATA.xls"
Exit Sub
End If


Regards

Stephen


---
Message posted from http://www.ExcelForum.com/

.


Stephen[_12_]

Return to Original File
 
Hi Frank,

The code works great:) Thanks a million!!

Stephen



Frank Kabel wrote:
*Hi
try
Dim wbk As Workbook
Dim old_book as workbook
set old_book=activeworkbook
On Error Resume Next
Set wbk = Workbooks("DATA.xls")
On Error GoTo 0
If wbk Is Nothing Then
Workbooks.Open Filename:= _
"C:\DATA.xls"
old_book.activate
Exit Sub
End If


-----Original Message-----
Hi peoples

I need to make an adjustment to my code. If it opens the

file DATA.xls
it needs to return to the original file (that was already

open). The
original file is different every month.

Dim wbk As Workbook
On Error Resume Next
Set wbk = Workbooks("DATA.xls")
On Error GoTo 0
If wbk Is Nothing Then
Workbooks.Open Filename:= _
"C:\DATA.xls"
Exit Sub
End If


Regards

Stephen


---
Message posted from http://www.ExcelForum.com/

.
*



---
Message posted from http://www.ExcelForum.com/



All times are GMT +1. The time now is 01:49 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com