Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 333
Default GetOpenFilename Close

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 333
Default GetOpenFilename Close

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 333
Default GetOpenFilename Close

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Before Close Event Hide all Worksheets then Close Application RyanH Excel Programming 0 January 24th 08 03:15 PM
Can I stop the close method in an auto close macro Paul Excel Programming 2 November 17th 06 02:48 PM
In Before Close Sub ActiveWorkBook.Close(False) repeat procedure [email protected] Excel Programming 5 September 26th 06 03:11 PM
Excel shoud not close all active books when clicking close button technomike Excel Discussion (Misc queries) 0 June 10th 05 05:35 PM
excel - Windows close button (x) should only close active workboo. CoffeeAdict Setting up and Configuration of Excel 3 February 8th 05 04:30 AM


All times are GMT +1. The time now is 03:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"