ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating a macro to open as save other selected Excel sheets (https://www.excelbanter.com/excel-programming/365610-creating-macro-open-save-other-selected-excel-sheets.html)

Wessie

Creating a macro to open as save other selected Excel sheets
 
How can one create a macro that open another workbook that detects if
the workbook is allready open? Example: If I run my macro to activate
the window,but the book is not open, it shows an error. The same if I
run my macro to open the workbook, but it is allready open it shows
errors.
I would aso like to know how my macro can detect, when saving a
spesific sheet in my workbook to a new workbook ander a given file
name(ex."BACKUPSHEET.xls"), if the name in that folder allready exists
and then save it with a simular name but not the same(ex: "BACKUPSHEET
1.xls").
I would appreciate it if some one can help me with these problems.


Norman Jones

Creating a macro to open as save other selected Excel sheets
 
Hi Wessie,

One way:

'=============
Public Sub Tester()
Dim wb As Workbook

On Error Resume Next
Set wb = Workbooks("YourBook.xls")
On Error GoTo 0

If wb Is Nothing Then
Workbooks.Open Filename:="YourBook.xls"
End If

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


--
---
Regards,
Norman



"Wessie" wrote in message
oups.com...
How can one create a macro that open another workbook that detects if
the workbook is allready open? Example: If I run my macro to activate
the window,but the book is not open, it shows an error. The same if I
run my macro to open the workbook, but it is allready open it shows
errors.
I would aso like to know how my macro can detect, when saving a
spesific sheet in my workbook to a new workbook ander a given file
name(ex."BACKUPSHEET.xls"), if the name in that folder allready exists
and then save it with a simular name but not the same(ex: "BACKUPSHEET
1.xls").
I would appreciate it if some one can help me with these problems.





All times are GMT +1. The time now is 10:00 PM.

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