PC Review


Reply
Thread Tools Rate Thread

AdvancedCommandBars

 
 
=?Utf-8?B?U3VuZGF5ODgzMTA=?=
Guest
Posts: n/a
 
      7th Sep 2007
Question is why (IsEmptyWorksheet) can hang up the running of the application
does this statement need a Dim
This statement produces all the system faces and takes 3 minutes to run.

Dim iFaceId As Integer ' Tracks Current FaceID
Dim iColumn As Integer ' Tracks Current column in worksheet
Dim iRow As Integer ' Tracks current Row in worksheet
Dim ctl As CommandBarControl
Dim cbr As CommandBar
If Not IsEmptyWorksheet(ActiveSheet) Then Exit Sub
On Error GoTo Recover
Application.ScreenUpdating = False
Set cbr = CommandBars.Add(Position:=msoBarFloating, MenuBar:=False,
temporary:=True)
Set ctl = cbr.Controls.Add(Type:=msoControlButton, temporary:=True)
iRow = 1
Do
For iColumn = 1 To 10
iFaceId = iFaceId + 1
Application.StatusBar = "FaceID = " & iFaceId
ctl.FaceId = iFaceId
ctl.CopyFace
ActiveSheet.Paste Cells(iRow, iColumn + 1)
Cells(iRow, iColumn).Value = iFaceId
Next iColumn
iRow = iRow + 1
Loop
Recover:
If Err.Number = 1004 Then Resume Next
Application.StatusBar = False
cbr.Delete



End Sub

--
William<"M"


 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      7th Sep 2007
It doesn't need a dim statement, but you do need to have a function with that
name.

Do you have a function like that that the calling sub can find?

If no, maybe you can use this one:

Function IsEmptyWorksheet(wks As Worksheet) As Boolean
If wks.UsedRange.Address = "$A$1" _
And IsEmpty(wks.Range("A1").Value) Then
IsEmptyWorksheet = True
Else
IsEmptyWorksheet = False
End If
End Function

Here are some alternatives, too:

Doug Glancy's:
http://www.dicks-blog.com/archives/2...-viewer-addin/

John Walkenbach's:
http://j-walk.com/ss/excel/tips/tip67.htm

Jim Rech's:
http://www.oaltd.co.uk/MVP/MVPPage.asp#JimRech

Jim's version for the Office2007 button images can be found on Ron de Bruin's
site:
http://www.rondebruin.nl/ribbon.htm
or directly from:
http://www.rondebruin.nl/files/BtnImages.zip


Sunday88310 wrote:
>
> Question is why (IsEmptyWorksheet) can hang up the running of the application
> does this statement need a Dim
> This statement produces all the system faces and takes 3 minutes to run.
>
> Dim iFaceId As Integer ' Tracks Current FaceID
> Dim iColumn As Integer ' Tracks Current column in worksheet
> Dim iRow As Integer ' Tracks current Row in worksheet
> Dim ctl As CommandBarControl
> Dim cbr As CommandBar
> If Not IsEmptyWorksheet(ActiveSheet) Then Exit Sub
> On Error GoTo Recover
> Application.ScreenUpdating = False
> Set cbr = CommandBars.Add(Position:=msoBarFloating, MenuBar:=False,
> temporary:=True)
> Set ctl = cbr.Controls.Add(Type:=msoControlButton, temporary:=True)
> iRow = 1
> Do
> For iColumn = 1 To 10
> iFaceId = iFaceId + 1
> Application.StatusBar = "FaceID = " & iFaceId
> ctl.FaceId = iFaceId
> ctl.CopyFace
> ActiveSheet.Paste Cells(iRow, iColumn + 1)
> Cells(iRow, iColumn).Value = iFaceId
> Next iColumn
> iRow = iRow + 1
> Loop
> Recover:
> If Err.Number = 1004 Then Resume Next
> Application.StatusBar = False
> cbr.Delete
>
> End Sub
>
> --
> William<"M"


--

Dave Peterson
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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



Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:49 AM.