Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default test that there is something to undo before executing application.

hi, is there a way to test that there is something to undo before executing
an Application.Undo?

Thanks,
pwrob
--
xl help seeker
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default test that there is something to undo before executing application.

This works ok in xl2003 in my USA/English version:

If Application.CommandBars("Standard").Controls("Undo ").Enabled = True Then
MsgBox "there's something to undo"
Else
MsgBox "nothing to undo"
End If



pwrob wrote:

hi, is there a way to test that there is something to undo before executing
an Application.Undo?

Thanks,
pwrob
--
xl help seeker


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default test that there is something to undo before executing application.

On Error Resume Next
ud = Application.CommandBars.FindControl(ID:=128).ListC ount
' could test for err.number, if 0 but ud=0
' probably means Redo has at least 1 item that'll
' get called with app.undo
On Error GoTo 0

Even though Commandbars are replaced with the Ribbon in 2007 this still
appears to work in 2007

If the intention is to call .Undo but you're only concerned about an error
if Undo is empty, just do simply

On error resume next
Application.Undo
On error goto 0

Regards,
Peter T


"pwrob" wrote in message
...
hi, is there a way to test that there is something to undo before
executing
an Application.Undo?

Thanks,
pwrob
--
xl help seeker



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default test that there is something to undo before executing applicat

great, thank you very much. cheers, pwrob
--
xl help seeker


"Dave Peterson" wrote:

This works ok in xl2003 in my USA/English version:

If Application.CommandBars("Standard").Controls("Undo ").Enabled = True Then
MsgBox "there's something to undo"
Else
MsgBox "nothing to undo"
End If



pwrob wrote:

hi, is there a way to test that there is something to undo before executing
an Application.Undo?

Thanks,
pwrob
--
xl help seeker


--

Dave Peterson
.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default test that there is something to undo before executing applicat

thank you for the prompt reply.

i know the app undo throws error 1004 if there is nothing to undo and i'm a
bit concerned that something else might throw the same error...

do you know whether i can place the on error resume next statement in the
middle of my sub? if so, will it apply to all code thereafter or from the
beginning of the sub?

thanks,
pwrob

--
xl help seeker


"Peter T" wrote:

On Error Resume Next
ud = Application.CommandBars.FindControl(ID:=128).ListC ount
' could test for err.number, if 0 but ud=0
' probably means Redo has at least 1 item that'll
' get called with app.undo
On Error GoTo 0

Even though Commandbars are replaced with the Ribbon in 2007 this still
appears to work in 2007

If the intention is to call .Undo but you're only concerned about an error
if Undo is empty, just do simply

On error resume next
Application.Undo
On error goto 0

Regards,
Peter T


"pwrob" wrote in message
...
hi, is there a way to test that there is something to undo before
executing
an Application.Undo?

Thanks,
pwrob
--
xl help seeker



.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default test that there is something to undo before executing applicat

hi again, just realized that ...goto 0 disables the error handling - this
will work! thanks again - cheers, pwrob
--
xl help seeker


"Peter T" wrote:

On Error Resume Next
ud = Application.CommandBars.FindControl(ID:=128).ListC ount
' could test for err.number, if 0 but ud=0
' probably means Redo has at least 1 item that'll
' get called with app.undo
On Error GoTo 0

Even though Commandbars are replaced with the Ribbon in 2007 this still
appears to work in 2007

If the intention is to call .Undo but you're only concerned about an error
if Undo is empty, just do simply

On error resume next
Application.Undo
On error goto 0

Regards,
Peter T


"pwrob" wrote in message
...
hi, is there a way to test that there is something to undo before
executing
an Application.Undo?

Thanks,
pwrob
--
xl help seeker



.

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
Application.undo runtime error '1004' Adam Excel Programming 1 October 15th 09 06:50 PM
Application.Undo failing with specific order of events Bill P Excel Programming 0 August 3rd 05 07:28 PM
Worksheet_Change and Application.undo Mangesh Yadav[_4_] Excel Programming 3 July 5th 05 12:16 PM
Test if application running? Chuck Excel Programming 1 December 7th 04 03:27 PM
Application.Undo Problem pgjoshi[_5_] Excel Programming 1 May 6th 04 01:42 PM


All times are GMT +1. The time now is 09:00 PM.

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

About Us

"It's about Microsoft Excel"