ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Dialog Box - User hits cancel (https://www.excelbanter.com/excel-programming/282608-dialog-box-user-hits-cancel.html)

Michael Hopwood

Dialog Box - User hits cancel
 
You need to trap the error and deal with it.

Post your code.

--
Michael Hopwood (Phobos)


"CS" wrote in message
...
I have a dialog box for inserting an image that pops up in my macro - if

the
user presses cancel - an error is reported (method not supported) how can

I
suppress this error?

Can I use some code like - if cancel is pressed exit sub?

Thanks,

Colin





CS[_2_]

Dialog Box - User hits cancel
 
I have a dialog box for inserting an image that pops up in my macro - if the
user presses cancel - an error is reported (method not supported) how can I
suppress this error?

Can I use some code like - if cancel is pressed exit sub?

Thanks,

Colin



CS[_2_]

Dialog Box - User hits cancel
 

Here is my code....

Sub InsertPictures()

Application.ScreenUpdating = False

Range("F3").Select
Application.Dialogs(xlDialogInsertPicture).Show
Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.ShapeRange.Height = 225#
Selection.ShapeRange.Width = 300#


Range("F23").Select
Application.Dialogs(xlDialogInsertPicture).Show
Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.ShapeRange.Height = 225#
Selection.ShapeRange.Width = 300#

Application.ScreenUpdating = True

ActiveWorkbook.Close (True)

End Sub



"Michael Hopwood" wrote in message
...
You need to trap the error and deal with it.

Post your code.

--
Michael Hopwood (Phobos)


"CS" wrote in message
...
I have a dialog box for inserting an image that pops up in my macro - if

the
user presses cancel - an error is reported (method not supported) how

can
I
suppress this error?

Can I use some code like - if cancel is pressed exit sub?

Thanks,

Colin







Tom Ogilvy

Dialog Box - User hits cancel
 
Range("F3").Select
If Application.Dialogs(xlDialogInsertPicture).Show Then
Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.ShapeRange.Height = 225#
Selection.ShapeRange.Width = 300#
End If

Range("F23").Select
If Application.Dialogs(xlDialogInsertPicture).Show Then
Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.ShapeRange.Height = 225#
Selection.ShapeRange.Width = 300#
End If

The dialog returns false if the user presses cancel.

--
Regards,
Tom Ogilvy



"CS" wrote in message
...

Here is my code....

Sub InsertPictures()

Application.ScreenUpdating = False

Range("F3").Select
Application.Dialogs(xlDialogInsertPicture).Show
Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.ShapeRange.Height = 225#
Selection.ShapeRange.Width = 300#


Range("F23").Select
Application.Dialogs(xlDialogInsertPicture).Show
Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.ShapeRange.Height = 225#
Selection.ShapeRange.Width = 300#

Application.ScreenUpdating = True

ActiveWorkbook.Close (True)

End Sub



"Michael Hopwood" wrote in message
...
You need to trap the error and deal with it.

Post your code.

--
Michael Hopwood (Phobos)


"CS" wrote in message
...
I have a dialog box for inserting an image that pops up in my macro -

if
the
user presses cancel - an error is reported (method not supported) how

can
I
suppress this error?

Can I use some code like - if cancel is pressed exit sub?

Thanks,

Colin









CS[_2_]

Dialog Box - User hits cancel
 
Worked a treat - thanks!

Colin

"Tom Ogilvy" wrote in message
...
Range("F3").Select
If Application.Dialogs(xlDialogInsertPicture).Show Then
Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.ShapeRange.Height = 225#
Selection.ShapeRange.Width = 300#
End If

Range("F23").Select
If Application.Dialogs(xlDialogInsertPicture).Show Then
Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.ShapeRange.Height = 225#
Selection.ShapeRange.Width = 300#
End If

The dialog returns false if the user presses cancel.

--
Regards,
Tom Ogilvy



"CS" wrote in message
...

Here is my code....

Sub InsertPictures()

Application.ScreenUpdating = False

Range("F3").Select
Application.Dialogs(xlDialogInsertPicture).Show
Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.ShapeRange.Height = 225#
Selection.ShapeRange.Width = 300#


Range("F23").Select
Application.Dialogs(xlDialogInsertPicture).Show
Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.ShapeRange.Height = 225#
Selection.ShapeRange.Width = 300#

Application.ScreenUpdating = True

ActiveWorkbook.Close (True)

End Sub



"Michael Hopwood" wrote in message
...
You need to trap the error and deal with it.

Post your code.

--
Michael Hopwood (Phobos)


"CS" wrote in message
...
I have a dialog box for inserting an image that pops up in my

macro -
if
the
user presses cancel - an error is reported (method not supported)

how
can
I
suppress this error?

Can I use some code like - if cancel is pressed exit sub?

Thanks,

Colin












All times are GMT +1. The time now is 10:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com