Form Coding not working

T

Texernie1

I have a Publisher (running 2003 SP2) document that I want to have modify a
particular item on different pages depending upon what I select in the drop
down on a form.

I have a userform with a command button and a drop down on it. The code
behind the form acts differently, depending upon the method of running it.

1) Running the code by putting the cursor inside Change_Number and stepping
through (F5 or F8). I see "I Run", "I Run3", and "I Run2". The drop down is
populated correctly, when I press the command button, I see "I Run4" and the
code executes correctly. The code stops when it encounters the "Stop" command.

2) Running the code by running it through the menu in Publisher, I see "I
Run" and "I Run2". The drop down is not populated correctly and nothing
happens when I press the command button. The code never enters tracing mode
when it encounters the "Stop" command.

Has anyone see this type of behavior before? Does anyone have any ideas on
how to correct the problem?

TIA
TexErnie1

(In Module1)
Sub Change_Number()

Stop

MsgBox ("I run")
Load PhoneNumbers
MsgBox ("I run2")
PhoneNumbers.Show

End Sub

(The Code behind PhoneNumbers)
Private Sub CommandButton1_Click()

MsgBox ("I Run4")

Phone = Me.ComboBox1.Value

'Stop

ThisDocument.Pages(1).Shapes.Item("WordArt 56").TextEffect.Text = Phone

'For Each I In ThisDocument.Pages(1).Shapes
'Stop
' Debug.Print I.Name
'Next I

Unload Me

End Sub


Private Sub UserForm_Initialize()

'Stop
MsgBox ("I Run3")

Me.ComboBox1.Clear

Me.ComboBox1.AddItem "xxx-xxx-xxxx"
Me.ComboBox1.AddItem "xxx-xxx-xxxx"
Me.ComboBox1.AddItem "xxx-xxx-xxxx"
Me.ComboBox1.AddItem "xxx-xxx-xxxx"
Me.ComboBox1.AddItem "xxx-xxx-xxxx"
Me.ComboBox1.AddItem "xxx-xxx-xxxx"


End Sub
 
T

Texernie1

Has anyone seen this issue bofore or been able to duplicate it?

Regards,
Texernie1
 
J

JoAnn Paules [MSFT MVP]

There aren't a lot of people who've done any programming in Publisher. It
may take a while for your question to get answered - if at all.
 
T

Texernie1

JoAnn,

Thanks. This would almost seem to be an issue with the VB that is
included in Publisher. As a programmer, I have never seen code act
differently between the step through mode and the full-speed mode.

I know that ofhter programming areas of the MSDN would probably earn me
a flaming for posting in the wrong forum.

The code is designed to change a specific item (the phone number) on
multiple pages of my document (each page is a different flier) for easy
custimization.

Regards,
TexErnie1


JoAnn Paules said:
There aren't a lot of people who've done any programming in Publisher. It
may take a while for your question to get answered - if at all.

--

JoAnn Paules
MVP Microsoft [Publisher]



Texernie1 said:
Has anyone seen this issue bofore or been able to duplicate it?

Regards,
Texernie1
 
J

JoAnn Paules [MSFT MVP]

I honestly don't know. I took one entry level class in programming and I
learned that I really suck at it. I'm glad I have many other skills that I
can use to earn a living. :)

--

JoAnn Paules
MVP Microsoft [Publisher]



Texernie1 said:
JoAnn,

Thanks. This would almost seem to be an issue with the VB that is
included in Publisher. As a programmer, I have never seen code act
differently between the step through mode and the full-speed mode.

I know that ofhter programming areas of the MSDN would probably earn
me
a flaming for posting in the wrong forum.

The code is designed to change a specific item (the phone number) on
multiple pages of my document (each page is a different flier) for easy
custimization.

Regards,
TexErnie1


JoAnn Paules said:
There aren't a lot of people who've done any programming in Publisher. It
may take a while for your question to get answered - if at all.

--

JoAnn Paules
MVP Microsoft [Publisher]



Texernie1 said:
Has anyone seen this issue bofore or been able to duplicate it?

Regards,
Texernie1

:

I have a Publisher (running 2003 SP2) document that I want to have
modify
a
particular item on different pages depending upon what I select in the
drop
down on a form.

I have a userform with a command button and a drop down on it. The
code
behind the form acts differently, depending upon the method of running
it.

1) Running the code by putting the cursor inside Change_Number and
stepping
through (F5 or F8). I see "I Run", "I Run3", and "I Run2". The drop
down
is
populated correctly, when I press the command button, I see "I Run4"
and
the
code executes correctly. The code stops when it encounters the "Stop"
command.

2) Running the code by running it through the menu in Publisher, I see
"I
Run" and "I Run2". The drop down is not populated correctly and
nothing
happens when I press the command button. The code never enters tracing
mode
when it encounters the "Stop" command.

Has anyone see this type of behavior before? Does anyone have any
ideas
on
how to correct the problem?

TIA
TexErnie1

(In Module1)
Sub Change_Number()

Stop

MsgBox ("I run")
Load PhoneNumbers
MsgBox ("I run2")
PhoneNumbers.Show

End Sub

(The Code behind PhoneNumbers)
Private Sub CommandButton1_Click()

MsgBox ("I Run4")

Phone = Me.ComboBox1.Value

'Stop

ThisDocument.Pages(1).Shapes.Item("WordArt 56").TextEffect.Text =
Phone

'For Each I In ThisDocument.Pages(1).Shapes
'Stop
' Debug.Print I.Name
'Next I

Unload Me

End Sub


Private Sub UserForm_Initialize()

'Stop
MsgBox ("I Run3")

Me.ComboBox1.Clear

Me.ComboBox1.AddItem "xxx-xxx-xxxx"
Me.ComboBox1.AddItem "xxx-xxx-xxxx"
Me.ComboBox1.AddItem "xxx-xxx-xxxx"
Me.ComboBox1.AddItem "xxx-xxx-xxxx"
Me.ComboBox1.AddItem "xxx-xxx-xxxx"
Me.ComboBox1.AddItem "xxx-xxx-xxxx"


End Sub
 
E

Ed Bennett

Texernie1 said:
Thanks. This would almost seem to be an issue with the VB that is
included in Publisher. As a programmer, I have never seen code act
differently between the step through mode and the full-speed mode.

I have observed that when programming Publisher with .NET, some statements
are skipped when running in Release (full-speed) mode but not when running
with a debugger attached.

I have never observed this when not using the PIAs, though, so I assumed it
was an issue with the PIAs.


Looking through some technical articles, I find that the way I've always
worked with VB forms is not the way you're supposed to work with UserForms.
The UserForm is a template, you need to create a specific instance when you
call it from code.

e.g.

Dim myForm As New PhoneNumbers
Load myForm
myForm.Show

HTH
 
T

Texernie1

Ed,

Thanks for the input. Unfortunately, it did not work. I even added a
DoEvents right after the load with no success. New code is below. Results are
identical as before.

Maybe someone has a better idea as to how to chage specific items on the
pages (in my case the text of wordart on 4 pages) at will? I don't want to
have to copy the pages and change the phone number on each page (I have at
least 6 phone numbers) as this expands my document to 24 pages really quick
and makes changing the designs tough.

Regards,
TexErnie1

Sub Change_Number()

Dim myForm As New PhoneNumbers

MsgBox ("I run")
Load myForm
DoEvents
MsgBox ("I run2")
myForm.Show

End Sub
 
E

Ed Bennett

Texernie1 said:
Thanks for the input. Unfortunately, it did not work. I even added
a DoEvents right after the load with no success. New code is below.
Results are identical as before.

You could try moving the code from the Initialize event to the Load event,
provided you make sure you unload the form after each use.

Why are you populating the ComboBox at runtime anyway?
 
T

Texernie1

Ed,

Thanks for the input again. I changed the code to the Load event, but
still no luck. It seems that all the code attached to the form itself has
been disabled. When I click the button on the form, it does nothing. I just
don't understand it. I may have to find an alternate way of doing what I am
needing.

I was loading the dropdown at execution time becuase the properties for
the drop down seem to act differently in Publisher than in most Office
programs. It seems that VB in general acts differently in Publisher than in
the rest of the Office Programs.


Regards,
TexErnie1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top