Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 29th, 2005, 08:35 PM
Registered User
Join Date: Dec 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Face ID Code not working for me

I have downloaded the code that appears on p206 of John Green's "Excel 2000 VBA Programmer's Reference" and I can't get it to work.
Absolutely nothing happens. The Do loop is not entered because Err.Number = 91.
When I comment out the "On Error Resume Next" and Debug>Step Into>F8...
the error 91: "Object variable or With block variable not set" occurs as soon as I press F8 to go from:

Set cbBar = CommandBars.Add(Position:=msoBarFloating, MenuBar:=False, temporary:=True)


Set cbCtl = cbBar.Controls.Add(Type:=msoControlButton, temporary:=True)

That's as far as I can go without assistance.
Can anybody spot the problem?

See code below...

Sub ListAllFaces()
   Dim i As Integer
   Dim j As Integer
   Dim k As Integer
   Dim cbCtl As CommandBarControl
   Dim cbBar As CommandBar

   On Error Resume Next
   Application.ScreenUpdating = False
   Set cbBar = CommandBars.Add(Position:=msoBarFloating, _
   MenuBar:=False, temporary:=True)
   Set cbCtl = cbBar.Controls.Add(Type:=msoControlButton, _
   k = 1
   Do While Err.Number = 0
      For j = 1 To 10
         i = i + 1
         Application.StatusBar = "FaceID = " & i
         cbCtl.FaceId = i
         If Err.Number <> 0 Then Exit For
         ActiveSheet.Paste Cells(k, j + 1)
         Cells(k, j).Value = i
      Next j
      k = k + 1
   Application.StatusBar = False
End Sub

Ken Johnson

Similar Threads
Thread Thread Starter Forum Replies Last Post
Get most recently inserted ID code mat41 Classic ASP Professional 17 May 2nd, 2006 02:19 AM
create a unique id in asp code langer123 Classic ASP Basics 1 March 15th, 2005 03:55 AM
font face crmpicco HTML Code Clinic 1 February 18th, 2005 07:38 AM
User Control Id not working duncanthescott Pro VB.NET 2002/2003 4 September 23rd, 2003 11:44 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.