Using the built-in dialog to format a shape

T

Tim Saunders

I am sure I am missing something obvious...
Just upgraded to Office XP. Previously did this with no problems:
Sheets("Drawing").Drawings("Line1").Select
Application.Dialogs(xlDialogPatterns).Show
but now it seems I have to use shapes instead of drawings and the following code does not work and I cannot find a fix:
Sheets("Drawing").Shapes("Line1").Select
Application.Dialogs(xlDialogPatterns).Show
 
G

Greg Wilson

I'm not running XP but I suspect your problem is a simple
spelling error of the line name. Note that when you add a
line to a worksheet, the default names are "Line" followed
by a space and then a number (eg. "Line 1"). Your spelling
excludes a space. Your code works for me if I spell the
line name correctly.

Regards,
Greg
-----Original Message-----
I am sure I am missing something obvious...
Just upgraded to Office XP. Previously did this with no problems:
Sheets("Drawing").Drawings("Line1").Select
Application.Dialogs(xlDialogPatterns).Show
but now it seems I have to use shapes instead of drawings
and the following code does not work and I cannot find a
fix:
 
G

Greg Wilson

Tim,

I prefer the command bar "Line Color" for doing what
you're trying to do. I suggest this instead:
Application.CommandBars("Line Color").Visible = True

I am assuming at this point that xl2003 has changed the
dialog referencing which is causing your problem. The
statement xlDialogPatterns is just a system constant for
an integer value; i.e., MsgBox xlDialogPatters returns 84.
You can scroll the entire collection using a loop while
incrementing an integer variable. Note that the collection
is extremely long - roughly four hundred if I remember
correctly. You'll need to abort using Ctrl + Break (or
Pause). Alternatively, break up the loop into shorter runs
(1 to 50 then 51 to 100 etc.). Suggested code:

Sub ShowDialogs()
Dim i As Integer
On Error Resume Next
For i = 1 To Application.Dialogs.Count
Application.Dialogs(i).Show
MsgBox i
Next
End Sub

Regards,
Greg




-----Original Message-----
Thanks but that's not it - my code actually takes the
line name from a varable but I replaced it with "Line1" to
try and simplify things here. The line gets selected
successfully, that's not the problem, but the next line of
code generates a run-time error 1004 "Show method of
Dialog class failed". Any more ideas anybody?
 
Top