Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 ! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 ! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 ! |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 ! |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Syntax to close Workbook
Jacob, this is great man !
Thank you very much for the tip. Both methods worked perfectly ! Tks. =) |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 ! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
VB Syntax to close Excel workbook not saving changes | Excel Programming | |||
Hide all Sheets in Workbook then Close Workbook | Excel Programming | |||
Open New Workbook / Save and Close Current Workbook | Excel Programming | |||
Help on Workbook close and workbook save events | Excel Programming | |||
Close a the current workbook and load another specified workbook | Excel Programming |