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 said:
Hi,
How do I catch it if the user closes the GetOpenFilename window with the
titlebar 'X' so my code doesn't error out?