ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Syntax to close Workbook (https://www.excelbanter.com/excel-programming/432782-syntax-close-workbook.html)

Eddie_SP[_2_]

Syntax to close Workbook
 
Hi !

I have one Multipage with 6 pages.
When I click on the last page, it opens a workbook from the Server.
But when people click on any other page instead of last one, I need a
command to close this activeworkbook.

I tried in "Select Case" but it doesn't help me, because I will have to
change the body of the program...

I just needed something like:

IF ACTIVEWORKBOOK IS DIFFERENT FROM THIS WORKBOOK THEN

ACTIVEWORKBOOK.CLOSE FALSE


I just do not get the right syntax...


And if someone has a tip to give me about closing this recently opened file
in case someone choose another page, please feel free, it would help me a
lot !

Patrick Molloy[_2_]

Syntax to close Workbook
 
If ActiveWorkbook.Name < ThisWorkbook.Name then
ActiveWorkbook.Close false
End If

"Eddie_SP" wrote:

Hi !

I have one Multipage with 6 pages.
When I click on the last page, it opens a workbook from the Server.
But when people click on any other page instead of last one, I need a
command to close this activeworkbook.

I tried in "Select Case" but it doesn't help me, because I will have to
change the body of the program...

I just needed something like:

IF ACTIVEWORKBOOK IS DIFFERENT FROM THIS WORKBOOK THEN

ACTIVEWORKBOOK.CLOSE FALSE


I just do not get the right syntax...


And if someone has a tip to give me about closing this recently opened file
in case someone choose another page, please feel free, it would help me a
lot !


Eddie_SP[_2_]

Syntax to close Workbook
 
That's it Mr. Patrick Molloy ! \o/

Thank you man !!!



"Patrick Molloy" wrote:

If ActiveWorkbook.Name < ThisWorkbook.Name then
ActiveWorkbook.Close false
End If

"Eddie_SP" wrote:

Hi !

I have one Multipage with 6 pages.
When I click on the last page, it opens a workbook from the Server.
But when people click on any other page instead of last one, I need a
command to close this activeworkbook.

I tried in "Select Case" but it doesn't help me, because I will have to
change the body of the program...

I just needed something like:

IF ACTIVEWORKBOOK IS DIFFERENT FROM THIS WORKBOOK THEN

ACTIVEWORKBOOK.CLOSE FALSE


I just do not get the right syntax...


And if someone has a tip to give me about closing this recently opened file
in case someone choose another page, please feel free, it would help me a
lot !


Jacob Skaria

Syntax to close Workbook
 
Hi

Another way to deal with that is to store the workbook names in the Tag
property of each Page; and use the Change event; to close if open and Open
the workbook related to that page....

Dim wb As Workbook
Private Sub MultiPage1_Change()
If Not wb Is Nothing Then wb.Close False
Set wb = Workbooks.Open("c:\" & MultiPage1.SelectedItem.Tag)
'your code continues
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Eddie_SP" wrote:

Hi !

I have one Multipage with 6 pages.
When I click on the last page, it opens a workbook from the Server.
But when people click on any other page instead of last one, I need a
command to close this activeworkbook.

I tried in "Select Case" but it doesn't help me, because I will have to
change the body of the program...

I just needed something like:

IF ACTIVEWORKBOOK IS DIFFERENT FROM THIS WORKBOOK THEN

ACTIVEWORKBOOK.CLOSE FALSE


I just do not get the right syntax...


And if someone has a tip to give me about closing this recently opened file
in case someone choose another page, please feel free, it would help me a
lot !


Eddie_SP[_2_]

Syntax to close Workbook
 
Jacob, this is great man !

Thank you very much for the tip.

Both methods worked perfectly !

Tks. =)

Jacob Skaria

Syntax to close Workbook
 
Do you mean

Sub Macro1()
ActiveSheet.Columns(7).Insert
ActiveSheet.Range("G1") = "Title"
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Eddie_SP" wrote:

Hi !

I have one Multipage with 6 pages.
When I click on the last page, it opens a workbook from the Server.
But when people click on any other page instead of last one, I need a
command to close this activeworkbook.

I tried in "Select Case" but it doesn't help me, because I will have to
change the body of the program...

I just needed something like:

IF ACTIVEWORKBOOK IS DIFFERENT FROM THIS WORKBOOK THEN

ACTIVEWORKBOOK.CLOSE FALSE


I just do not get the right syntax...


And if someone has a tip to give me about closing this recently opened file
in case someone choose another page, please feel free, it would help me a
lot !



All times are GMT +1. The time now is 09:05 PM.

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