Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
How do I catch it if the user closes the GetOpenFilename window with the titlebar 'X' so my code doesn't error out? -- Thanks for your help. Karen53 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
To clarify, if they click the 'X' or cancel, how can I identify this so my code stops running? Sub wkbookCreate() Dim wbkCopyFrom As Workbook Dim rngCopyFrom As Range Dim rngCopyTo As Range Dim FromwbkName As String Dim FromPath As String Dim FromwbkPath As String FromwbkPath = Application.GetOpenFilename Call GetNamePath(FromwbkName, FromPath, FromwbkPath) On Error Resume Next Set wbkCopyFrom = Workbooks(FromwbkPath) If wbkCopyFrom Is Nothing Then Set wbkCopyFrom = Workbooks.Open(FromwbkPath) On Error GoTo 0 If wbkCopyFrom Is Nothing Then MsgBox "Cannot find originating file" Else Application.ScreenUpdating = False ThisWorkbook.Sheets((Replace(Tablespg.Name, "'", "''"))).Unprotect Password:=([MyPassword]) 'Pool lists 'CAM Set rngCopyFrom = wbkCopyFrom.Sheets(Replace(Tablespg.Name, "'", "''")).Range("J4:J21") Set rngCopyTo = ThisWorkbook.Sheets(Replace(Tablespg.Name, "'", "''")).Range("J4:J21") rngCopyTo.Value = rngCopyFrom.Value 'Tax Set rngCopyFrom = wbkCopyFrom.Sheets(Replace(Tablespg.Name, "'", "''")).Range("M4:M21") Set rngCopyTo = ThisWorkbook.Sheets(Replace(Tablespg.Name, "'", "''")).Range("M4:M21") rngCopyTo.Value = rngCopyFrom.Value ThisWorkbook.Sheets(Replace(Tablespg.Name, "'", "''")).Protect Password:=([MyPassword]) End If End If ActiveWorkbook.SaveAs Filename:=FromPath & FromwbkName & " Final.xls" Application.ScreenUpdating = True End Sub -- Thanks for your help. Karen53 "Karen53" wrote: Hi, How do I catch it if the user closes the GetOpenFilename window with the titlebar 'X' so my code doesn't error out? -- Thanks for your help. Karen53 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Never Mind. I've got this one. Thx
-- Thanks for your help. Karen53 "Karen53" wrote: Hi, To clarify, if they click the 'X' or cancel, how can I identify this so my code stops running? Sub wkbookCreate() Dim wbkCopyFrom As Workbook Dim rngCopyFrom As Range Dim rngCopyTo As Range Dim FromwbkName As String Dim FromPath As String Dim FromwbkPath As String FromwbkPath = Application.GetOpenFilename Call GetNamePath(FromwbkName, FromPath, FromwbkPath) On Error Resume Next Set wbkCopyFrom = Workbooks(FromwbkPath) If wbkCopyFrom Is Nothing Then Set wbkCopyFrom = Workbooks.Open(FromwbkPath) On Error GoTo 0 If wbkCopyFrom Is Nothing Then MsgBox "Cannot find originating file" Else Application.ScreenUpdating = False ThisWorkbook.Sheets((Replace(Tablespg.Name, "'", "''"))).Unprotect Password:=([MyPassword]) 'Pool lists 'CAM Set rngCopyFrom = wbkCopyFrom.Sheets(Replace(Tablespg.Name, "'", "''")).Range("J4:J21") Set rngCopyTo = ThisWorkbook.Sheets(Replace(Tablespg.Name, "'", "''")).Range("J4:J21") rngCopyTo.Value = rngCopyFrom.Value 'Tax Set rngCopyFrom = wbkCopyFrom.Sheets(Replace(Tablespg.Name, "'", "''")).Range("M4:M21") Set rngCopyTo = ThisWorkbook.Sheets(Replace(Tablespg.Name, "'", "''")).Range("M4:M21") rngCopyTo.Value = rngCopyFrom.Value ThisWorkbook.Sheets(Replace(Tablespg.Name, "'", "''")).Protect Password:=([MyPassword]) End If End If ActiveWorkbook.SaveAs Filename:=FromPath & FromwbkName & " Final.xls" Application.ScreenUpdating = True End Sub -- Thanks for your help. Karen53 "Karen53" wrote: Hi, How do I catch it if the user closes the GetOpenFilename window with the titlebar 'X' so my code doesn't error out? -- Thanks for your help. Karen53 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Before Close Event Hide all Worksheets then Close Application | Excel Programming | |||
Can I stop the close method in an auto close macro | Excel Programming | |||
In Before Close Sub ActiveWorkBook.Close(False) repeat procedure | Excel Programming | |||
Excel shoud not close all active books when clicking close button | Excel Discussion (Misc queries) | |||
excel - Windows close button (x) should only close active workboo. | Setting up and Configuration of Excel |