A small child turns to Ed, and exclaims: "Look! Look! A post from
Colonel Blip <colonel.blip@removethespambigfoot.com>!"...
> Got it!! (almost). I have two different macros and they run fine,
> even to the point of placing one on my custom bar. However, there is
> a 'quirk' in all of this. When I open publisher, and then select a
> template the macro button SPACE shows up on the command bar, however
> the button itself doesn't show up until I run the mouse over the area.
I tend to look at it as the button does show up, but the button face image
does not.
It also happens over here - minimizing and re-maximizing sorted it, so this
code snipped should sort it:
Dim InitialWindowState As Integer
InitialWindowState = ThisDocument.ActiveWindow.WindowState
ThisDocument.ActiveWindow.WindowState = pbWindowStateMinimize
ThisDocument.ActiveWindow.WindowState = InitialWindowState
> Further, I can not get the button for the 2nd macro to show up on the
> command bar when I open the template; I have to manually run the
> macro which sort of defeats the whole purpose.
Do you have a SINGLE Document_Open macro?
Do you have BOTH CommandBars("Add-ins").Add() statements in it?
> p.s. Love Publisher but it would sure be nice if macro building etc.
> were more like Word. <g>
Publisher has only had VBA since Publisher 2002 - Word has had VBA since
either Word for Windows 95 or Word 97 - and WordBasic since Word for Windows
Version 2.0 - so Word's VBA is a little more mature than Publisher's :-)

Signature
Ed Bennett - MVP Microsoft Publisher
http://www.mvps.org/the_nerd/
Before reading this message, view the disclaimer:
http://mvps.org/the_nerd/disclaim.htm
Colonel Blip - 16 Oct 2004 20:45 GMT
Hello, Ed!
You wrote on Sat, 16 Oct 2004 12:57:12 +0100:
EB> Dim InitialWindowState As Integer
EB> InitialWindowState = ThisDocument.ActiveWindow.WindowState
EB> ThisDocument.ActiveWindow.WindowState = pbWindowStateMinimize
EB> ThisDocument.ActiveWindow.WindowState = InitialWindowState
EB> Do you have a SINGLE Document_Open macro?
EB> Do you have BOTH CommandBars("Add-ins").Add() statements in it?
Ed,
I wasn't sure where the new code went so I made a stab at it and I was able to compile fine but it had no impact on the problems I described. I've included my VBA code below and you'll be able to see how I've coded all of it. I probably have the minimize/initial window state code more than I need it (twice) but wasn't sure.
Thanks,
Colonel Blip.
E-mail: colonel.blip@removethespambigfoot.com
Dim WithEvents cbbMyButton As Office.CommandBarButton
Dim WithEvents cbbMyButton1 As Office.CommandBarButton
Dim InitialWindowState As Integer
'This will handle 4x6 resizing
Private Sub cbbMyButton_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
With ThisDocument.Selection
If Not .ShapeRange.Count = 1 Then
Beep
Else
With .ShapeRange(1)
If .Width >= .Height Then
.Width = 432
.Height = 288
Else
.Width = 288
.Height = 432
End If
End With
End If
End With
End Sub
Private Sub Document_BeforeClose(Cancel As Boolean)
On Error Resume Next
CommandBars(3).Controls("Resize selection to 6"" by 4""").Delete
End Sub
Private Sub Document_Open()
InitialWindowState = ThisDocument.ActiveWindow.WindowState
ThisDocument.ActiveWindow.WindowState = pbWindowStateMinimize
ThisDocument.ActiveWindow.WindowState = InitialWindowState
On Error Resume Next
Set cbbMyButton = CommandBars(3).Controls.Add(, , , , True)
cbbMyButton.FaceId = 181
cbbMyButton.Caption = "Resize selection to 6"" by 4"""
End Sub
'This is to handle 8x10 resizing
Private Sub cbbMyButton1_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
With ThisDocument.Selection
If Not .ShapeRange.Count = 1 Then
Beep
Else
With .ShapeRange(1)
If .Width >= .Height Then
.Width = 720
.Height = 576
Else
.Width = 576
.Height = 720
End If
End With
End If
End With
End Sub
Private Sub Document_BeforeClose1(Cancel As Boolean)
On Error Resume Next
CommandBars("WLO Custom").Controls("Resize selection to 10"" by 8""").Delete
End Sub
Private Sub Document_Open1()
InitialWindowState = ThisDocument.ActiveWindow.WindowState
ThisDocument.ActiveWindow.WindowState = pbWindowStateMinimize
ThisDocument.ActiveWindow.WindowState = InitialWindowState
On Error Resume Next
Set cbbMyButton1 = CommandBars("WLO Custom").Controls.Add(, , , , True)
cbbMyButton1.FaceId = 185
cbbMyButton1.Caption = "Resize selection to 10"" by 8"""
End Sub
Ed Bennett - 17 Oct 2004 14:26 GMT
Ed looks left. Ed looks right. No-one is there. Furtively, Ed picks up
a note from Colonel Blip <colonel.blip@removethespambigfoot.com>. On it
is written:
> I wasn't sure where the new code went so I made a stab at it and I
> was able to compile fine but it had no impact on the problems I
> described. I've included my VBA code below and you'll be able to see
> how I've coded all of it. I probably have the minimize/initial window
> state code more than I need it (twice) but wasn't sure.
The Document_Open subroutine is called when the publication is opened.
Document_Open1 is not (as it does not handle an event).
Cut and paste the code from Document_Open1 into the end of Document_Open.
Ditto that for Document_BeforeClose.
Now, if you notice, when the ghost button is added, minimizing and restoring
the window makes it appear. It will not make it appear until the button has
been added in code.
The code I wrote just minimizes and restores the window. So the code needs
to be added (only once - it will appear twice if you do the copy and paste
suggested above) AFTER the code to create the buttons, as we want the
buttons to be created, then to minimize and restore the window.

Signature
Ed Bennett - MVP Microsoft Publisher
http://www.mvps.org/the_nerd/
Before reading this message, view the disclaimer:
http://mvps.org/the_nerd/disclaim.htm
Colonel Blip - 17 Oct 2004 21:11 GMT
Hello, Ed!
You wrote on Sun, 17 Oct 2004 14:26:40 +0100:
<SNIP>
Well, it took a while but finally my dense brain actually was able to "see"
what was going on in all of this code and I've modified it and even added to
it and it is all working great now.
BTW, I emailed you from your web page and it bounced. I've tried again and
so far the second attempt has not come back on me.
Thanks again for your help. Now I need to see what else I would like to
'automate'. <g>
Colonel Blip.
E-mail: colonel.blip@removethespambigfoot.com