user cancels

G

grt

hi,
The following subroutine works great. Though I would like
to have a msgbox appear if the user cancels. Any suggestions?

Sub ImportSome()
Workbooks.OpenText FileName:=Application.GetOpenFilename, _
StartRow:=1, DataType:=xlDelimited,.......
End Sub
 
J

JE McGimpsey

grt said:
hi,
The following subroutine works great. Though I would like
to have a msgbox appear if the user cancels. Any suggestions?

Sub ImportSome()
Workbooks.OpenText FileName:=Application.GetOpenFilename, _
StartRow:=1, DataType:=xlDelimited,.......
End Sub

One way:

Public Sub ImportSome()
Dim vFileName As Variant
vFileName = Application.GetOpenFilename
If vFileName = False Then
MsgBox "User cancelled"
Else
Workbooks.OpenText _
Filename:=vFileName, _
StartRow:=1, _
DataType:=xlDelimited
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top