Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
owen owen is offline
external usenet poster
 
Posts: 61
Default Activex Control in Word Document

I am using an activex control (combobox) in a macro that exists within my
word document. I have attached my code below.

The problem is that even when the combobox selection is NOT equal to CLAY,
the macro still executes the code as if the combobox selection was CLAY.

Prehaps the "if result =" method is not valid here?

Appreciate any help you can offer.

Sub test()
Dim CB26 As Object
Set CB26 = ActiveDocument.ComboBox26
With CB26
If Result = CLAY Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
Selection.MoveRight unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Selection.Copy
Selection.GoTo What:=wdGoToBookmark, Name:="Result1"
Selection.Paste
Else
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
Selection.MoveRight unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Selection.Copy
Selection.GoTo What:=wdGoToBookmark, Name:="Result1"
Selection.Paste
End If
End With
End Sub
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
macropod[_2_] macropod[_2_] is offline
external usenet poster
 
Posts: 2,059
Default Activex Control in Word Document

Hi Owen,

Try something along the lines of:
Sub test()
If ActiveDocument.ComboBox26.Text = "CLAY" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
Else
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
End If
With Selection
.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
.Copy
.GoTo What:=wdGoToBookmark, Name:="Result1"
.Paste
End With
End Sub

--
Cheers
macropod
[Microsoft MVP - Word]


"Owen" wrote in message ...
I am using an activex control (combobox) in a macro that exists within my
word document. I have attached my code below.

The problem is that even when the combobox selection is NOT equal to CLAY,
the macro still executes the code as if the combobox selection was CLAY.

Prehaps the "if result =" method is not valid here?

Appreciate any help you can offer.

Sub test()
Dim CB26 As Object
Set CB26 = ActiveDocument.ComboBox26
With CB26
If Result = CLAY Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
Selection.MoveRight unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Selection.Copy
Selection.GoTo What:=wdGoToBookmark, Name:="Result1"
Selection.Paste
Else
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
Selection.MoveRight unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Selection.Copy
Selection.GoTo What:=wdGoToBookmark, Name:="Result1"
Selection.Paste
End If
End With
End Sub

  #3   Report Post  
Posted to microsoft.public.word.docmanagement
owen owen is offline
external usenet poster
 
Posts: 61
Default Activex Control in Word Document

Hi Macropod

Thanks for the response. You have solved my initial problem. I now have
encountered another problem when trying to extend my code. I have pasted the
code below. The problem occurs at the first line in the debugger, where i
have used the AND and OR statements. I get a message saying "Type Mismatch".

Any thoughts here?

Thanks again for your time.

Sub test()
If ActiveDocument.ComboBox26.Text = "CLAY" And
ActiveDocument.ComboBox11.Text = "calcareous" Or "carbonate" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample6"
Else
If ActiveDocument.ComboBox26.Text = "CLAY" And
ActiveDocument.ComboBox1.Text = "Slightly cemented" Or "Moderately cemented"
Or "Well cemented" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
Else
If ActiveDocument.ComboBox26.Text = "CLAY" And
ActiveDocument.ComboBox1.Text = "Very weak" Or "Weak" Or "Moderately weak" Or
"Moderately strong" Or "Strong" Or "Very strong" Or "Extremely strong" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample16"
Else
If ActiveDocument.ComboBox26.Text = "CLAY" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
End If
End If
End If
End If
With Selection
.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
.Copy
.GoTo What:=wdGoToBookmark, Name:="Result1"
.Paste
End With
End Sub

"macropod" wrote:

Hi Owen,

Try something along the lines of:
Sub test()
If ActiveDocument.ComboBox26.Text = "CLAY" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
Else
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
End If
With Selection
.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
.Copy
.GoTo What:=wdGoToBookmark, Name:="Result1"
.Paste
End With
End Sub

--
Cheers
macropod
[Microsoft MVP - Word]


"Owen" wrote in message ...
I am using an activex control (combobox) in a macro that exists within my
word document. I have attached my code below.

The problem is that even when the combobox selection is NOT equal to CLAY,
the macro still executes the code as if the combobox selection was CLAY.

Prehaps the "if result =" method is not valid here?

Appreciate any help you can offer.

Sub test()
Dim CB26 As Object
Set CB26 = ActiveDocument.ComboBox26
With CB26
If Result = CLAY Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
Selection.MoveRight unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Selection.Copy
Selection.GoTo What:=wdGoToBookmark, Name:="Result1"
Selection.Paste
Else
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
Selection.MoveRight unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Selection.Copy
Selection.GoTo What:=wdGoToBookmark, Name:="Result1"
Selection.Paste
End If
End With
End Sub


  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Activex Control in Word Document

Try

If ActiveDocument.ComboBox26.Text = "CLAY" Then
Select Case ActiveDocument.ComboBox1.Text
Case "calcareous" Or "carbonate"
Selection.GoTo What:=wdGoToBookmark, Name:="Sample6"
Case "Slightly cemented" Or "Moderately cemented" Or "Well cemented"
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
Case "Very weak" Or "Weak" Or "Moderately weak" Or "Moderately
strong" _
Or "Strong" Or "Very strong" Or "Extremely strong"
Selection.GoTo What:=wdGoToBookmark, Name:="Sample16"
Case Else
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
End Select
End If
With Selection
.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
.Copy
.GoTo What:=wdGoToBookmark, Name:="Result1"
.Paste
End With

I think that your logic might need a bit of work. What about the case where
ComboBox26.Text "CLAY"

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Owen" wrote in message
...
Hi Macropod

Thanks for the response. You have solved my initial problem. I now have
encountered another problem when trying to extend my code. I have pasted
the
code below. The problem occurs at the first line in the debugger, where i
have used the AND and OR statements. I get a message saying "Type
Mismatch".

Any thoughts here?

Thanks again for your time.

Sub test()
If ActiveDocument.ComboBox26.Text = "CLAY" And
ActiveDocument.ComboBox11.Text = "calcareous" Or "carbonate" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample6"
Else
If ActiveDocument.ComboBox26.Text = "CLAY" And
ActiveDocument.ComboBox1.Text = "Slightly cemented" Or "Moderately
cemented"
Or "Well cemented" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
Else
If ActiveDocument.ComboBox26.Text = "CLAY" And
ActiveDocument.ComboBox1.Text = "Very weak" Or "Weak" Or "Moderately weak"
Or
"Moderately strong" Or "Strong" Or "Very strong" Or "Extremely strong"
Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample16"
Else
If ActiveDocument.ComboBox26.Text = "CLAY" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
End If
End If
End If
End If
With Selection
.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
.Copy
.GoTo What:=wdGoToBookmark, Name:="Result1"
.Paste
End With
End Sub

"macropod" wrote:

Hi Owen,

Try something along the lines of:
Sub test()
If ActiveDocument.ComboBox26.Text = "CLAY" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
Else
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
End If
With Selection
.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
.Copy
.GoTo What:=wdGoToBookmark, Name:="Result1"
.Paste
End With
End Sub

--
Cheers
macropod
[Microsoft MVP - Word]


"Owen" wrote in message
...
I am using an activex control (combobox) in a macro that exists within
my
word document. I have attached my code below.

The problem is that even when the combobox selection is NOT equal to
CLAY,
the macro still executes the code as if the combobox selection was
CLAY.

Prehaps the "if result =" method is not valid here?

Appreciate any help you can offer.

Sub test()
Dim CB26 As Object
Set CB26 = ActiveDocument.ComboBox26
With CB26
If Result = CLAY Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
Selection.MoveRight unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Selection.Copy
Selection.GoTo What:=wdGoToBookmark, Name:="Result1"
Selection.Paste
Else
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
Selection.MoveRight unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Selection.Copy
Selection.GoTo What:=wdGoToBookmark, Name:="Result1"
Selection.Paste
End If
End With
End Sub



  #5   Report Post  
Posted to microsoft.public.word.docmanagement
owen owen is offline
external usenet poster
 
Posts: 61
Default Activex Control in Word Document

Hi Doug

I am going to read further into the Select Case function.

Initially though, i can't understand how the function would determine if
"calcareous" or "carbonate" are selected since nowhere is ComboBox11 (which
contains those values) referenced in the code you provided.

I'll do some more research on this function, but let me know if i am missing
something simple here.

Thanks again

"Doug Robbins - Word MVP" wrote:

Try

If ActiveDocument.ComboBox26.Text = "CLAY" Then
Select Case ActiveDocument.ComboBox1.Text
Case "calcareous" Or "carbonate"
Selection.GoTo What:=wdGoToBookmark, Name:="Sample6"
Case "Slightly cemented" Or "Moderately cemented" Or "Well cemented"
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
Case "Very weak" Or "Weak" Or "Moderately weak" Or "Moderately
strong" _
Or "Strong" Or "Very strong" Or "Extremely strong"
Selection.GoTo What:=wdGoToBookmark, Name:="Sample16"
Case Else
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
End Select
End If
With Selection
.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
.Copy
.GoTo What:=wdGoToBookmark, Name:="Result1"
.Paste
End With

I think that your logic might need a bit of work. What about the case where
ComboBox26.Text "CLAY"

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Owen" wrote in message
...
Hi Macropod

Thanks for the response. You have solved my initial problem. I now have
encountered another problem when trying to extend my code. I have pasted
the
code below. The problem occurs at the first line in the debugger, where i
have used the AND and OR statements. I get a message saying "Type
Mismatch".

Any thoughts here?

Thanks again for your time.

Sub test()
If ActiveDocument.ComboBox26.Text = "CLAY" And
ActiveDocument.ComboBox11.Text = "calcareous" Or "carbonate" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample6"
Else
If ActiveDocument.ComboBox26.Text = "CLAY" And
ActiveDocument.ComboBox1.Text = "Slightly cemented" Or "Moderately
cemented"
Or "Well cemented" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
Else
If ActiveDocument.ComboBox26.Text = "CLAY" And
ActiveDocument.ComboBox1.Text = "Very weak" Or "Weak" Or "Moderately weak"
Or
"Moderately strong" Or "Strong" Or "Very strong" Or "Extremely strong"
Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample16"
Else
If ActiveDocument.ComboBox26.Text = "CLAY" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
End If
End If
End If
End If
With Selection
.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
.Copy
.GoTo What:=wdGoToBookmark, Name:="Result1"
.Paste
End With
End Sub

"macropod" wrote:

Hi Owen,

Try something along the lines of:
Sub test()
If ActiveDocument.ComboBox26.Text = "CLAY" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
Else
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
End If
With Selection
.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
.Copy
.GoTo What:=wdGoToBookmark, Name:="Result1"
.Paste
End With
End Sub

--
Cheers
macropod
[Microsoft MVP - Word]


"Owen" wrote in message
...
I am using an activex control (combobox) in a macro that exists within
my
word document. I have attached my code below.

The problem is that even when the combobox selection is NOT equal to
CLAY,
the macro still executes the code as if the combobox selection was
CLAY.

Prehaps the "if result =" method is not valid here?

Appreciate any help you can offer.

Sub test()
Dim CB26 As Object
Set CB26 = ActiveDocument.ComboBox26
With CB26
If Result = CLAY Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
Selection.MoveRight unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Selection.Copy
Selection.GoTo What:=wdGoToBookmark, Name:="Result1"
Selection.Paste
Else
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
Selection.MoveRight unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Selection.Copy
Selection.GoTo What:=wdGoToBookmark, Name:="Result1"
Selection.Paste
End If
End With
End Sub





  #6   Report Post  
Posted to microsoft.public.word.docmanagement
owen owen is offline
external usenet poster
 
Posts: 61
Default Activex Control in Word Document

Sorry, ignore my last post...i see the reference to ComboBox1 now.

Time for a break, too many hours looking at the screen here.

Again, thanks for your help.

"Owen" wrote:

Hi Doug

I am going to read further into the Select Case function.

Initially though, i can't understand how the function would determine if
"calcareous" or "carbonate" are selected since nowhere is ComboBox11 (which
contains those values) referenced in the code you provided.

I'll do some more research on this function, but let me know if i am missing
something simple here.

Thanks again

"Doug Robbins - Word MVP" wrote:

Try

If ActiveDocument.ComboBox26.Text = "CLAY" Then
Select Case ActiveDocument.ComboBox1.Text
Case "calcareous" Or "carbonate"
Selection.GoTo What:=wdGoToBookmark, Name:="Sample6"
Case "Slightly cemented" Or "Moderately cemented" Or "Well cemented"
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
Case "Very weak" Or "Weak" Or "Moderately weak" Or "Moderately
strong" _
Or "Strong" Or "Very strong" Or "Extremely strong"
Selection.GoTo What:=wdGoToBookmark, Name:="Sample16"
Case Else
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
End Select
End If
With Selection
.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
.Copy
.GoTo What:=wdGoToBookmark, Name:="Result1"
.Paste
End With

I think that your logic might need a bit of work. What about the case where
ComboBox26.Text "CLAY"

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Owen" wrote in message
...
Hi Macropod

Thanks for the response. You have solved my initial problem. I now have
encountered another problem when trying to extend my code. I have pasted
the
code below. The problem occurs at the first line in the debugger, where i
have used the AND and OR statements. I get a message saying "Type
Mismatch".

Any thoughts here?

Thanks again for your time.

Sub test()
If ActiveDocument.ComboBox26.Text = "CLAY" And
ActiveDocument.ComboBox11.Text = "calcareous" Or "carbonate" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample6"
Else
If ActiveDocument.ComboBox26.Text = "CLAY" And
ActiveDocument.ComboBox1.Text = "Slightly cemented" Or "Moderately
cemented"
Or "Well cemented" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
Else
If ActiveDocument.ComboBox26.Text = "CLAY" And
ActiveDocument.ComboBox1.Text = "Very weak" Or "Weak" Or "Moderately weak"
Or
"Moderately strong" Or "Strong" Or "Very strong" Or "Extremely strong"
Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample16"
Else
If ActiveDocument.ComboBox26.Text = "CLAY" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
End If
End If
End If
End If
With Selection
.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
.Copy
.GoTo What:=wdGoToBookmark, Name:="Result1"
.Paste
End With
End Sub

"macropod" wrote:

Hi Owen,

Try something along the lines of:
Sub test()
If ActiveDocument.ComboBox26.Text = "CLAY" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
Else
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
End If
With Selection
.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
.Copy
.GoTo What:=wdGoToBookmark, Name:="Result1"
.Paste
End With
End Sub

--
Cheers
macropod
[Microsoft MVP - Word]


"Owen" wrote in message
...
I am using an activex control (combobox) in a macro that exists within
my
word document. I have attached my code below.

The problem is that even when the combobox selection is NOT equal to
CLAY,
the macro still executes the code as if the combobox selection was
CLAY.

Prehaps the "if result =" method is not valid here?

Appreciate any help you can offer.

Sub test()
Dim CB26 As Object
Set CB26 = ActiveDocument.ComboBox26
With CB26
If Result = CLAY Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
Selection.MoveRight unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Selection.Copy
Selection.GoTo What:=wdGoToBookmark, Name:="Result1"
Selection.Paste
Else
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
Selection.MoveRight unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Selection.Copy
Selection.GoTo What:=wdGoToBookmark, Name:="Result1"
Selection.Paste
End If
End With
End Sub



  #7   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Activex Control in Word Document

OK, I figured that the ComboBox11 was a type and should have been
ComboBox1.

I would suggest that you give the comboboxes names that have some meaning to
them.

It also reinforces my believe that your logic needs some work.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Owen" wrote in message
...
Hi Doug

I am going to read further into the Select Case function.

Initially though, i can't understand how the function would determine if
"calcareous" or "carbonate" are selected since nowhere is ComboBox11
(which
contains those values) referenced in the code you provided.

I'll do some more research on this function, but let me know if i am
missing
something simple here.

Thanks again

"Doug Robbins - Word MVP" wrote:

Try

If ActiveDocument.ComboBox26.Text = "CLAY" Then
Select Case ActiveDocument.ComboBox1.Text
Case "calcareous" Or "carbonate"
Selection.GoTo What:=wdGoToBookmark, Name:="Sample6"
Case "Slightly cemented" Or "Moderately cemented" Or "Well
cemented"
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
Case "Very weak" Or "Weak" Or "Moderately weak" Or "Moderately
strong" _
Or "Strong" Or "Very strong" Or "Extremely strong"
Selection.GoTo What:=wdGoToBookmark, Name:="Sample16"
Case Else
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
End Select
End If
With Selection
.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
.Copy
.GoTo What:=wdGoToBookmark, Name:="Result1"
.Paste
End With

I think that your logic might need a bit of work. What about the case
where
ComboBox26.Text "CLAY"

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Owen" wrote in message
...
Hi Macropod

Thanks for the response. You have solved my initial problem. I now have
encountered another problem when trying to extend my code. I have
pasted
the
code below. The problem occurs at the first line in the debugger, where
i
have used the AND and OR statements. I get a message saying "Type
Mismatch".

Any thoughts here?

Thanks again for your time.

Sub test()
If ActiveDocument.ComboBox26.Text = "CLAY" And
ActiveDocument.ComboBox11.Text = "calcareous" Or "carbonate" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample6"
Else
If ActiveDocument.ComboBox26.Text = "CLAY" And
ActiveDocument.ComboBox1.Text = "Slightly cemented" Or "Moderately
cemented"
Or "Well cemented" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
Else
If ActiveDocument.ComboBox26.Text = "CLAY" And
ActiveDocument.ComboBox1.Text = "Very weak" Or "Weak" Or "Moderately
weak"
Or
"Moderately strong" Or "Strong" Or "Very strong" Or "Extremely strong"
Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample16"
Else
If ActiveDocument.ComboBox26.Text = "CLAY" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
End If
End If
End If
End If
With Selection
.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
.Copy
.GoTo What:=wdGoToBookmark, Name:="Result1"
.Paste
End With
End Sub

"macropod" wrote:

Hi Owen,

Try something along the lines of:
Sub test()
If ActiveDocument.ComboBox26.Text = "CLAY" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
Else
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
End If
With Selection
.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
.Copy
.GoTo What:=wdGoToBookmark, Name:="Result1"
.Paste
End With
End Sub

--
Cheers
macropod
[Microsoft MVP - Word]


"Owen" wrote in message
...
I am using an activex control (combobox) in a macro that exists
within
my
word document. I have attached my code below.

The problem is that even when the combobox selection is NOT equal to
CLAY,
the macro still executes the code as if the combobox selection was
CLAY.

Prehaps the "if result =" method is not valid here?

Appreciate any help you can offer.

Sub test()
Dim CB26 As Object
Set CB26 = ActiveDocument.ComboBox26
With CB26
If Result = CLAY Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
Selection.MoveRight unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Selection.Copy
Selection.GoTo What:=wdGoToBookmark, Name:="Result1"
Selection.Paste
Else
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
Selection.MoveRight unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Selection.Copy
Selection.GoTo What:=wdGoToBookmark, Name:="Result1"
Selection.Paste
End If
End With
End Sub




  #8   Report Post  
Posted to microsoft.public.word.docmanagement
owen owen is offline
external usenet poster
 
Posts: 61
Default Activex Control in Word Document

I copied your code however i am now getting a message "Type Mismatch" at the
third line of code

Case "calcareous" Or "carbonate"

I am using Word 2003, could this have any effect?



"Doug Robbins - Word MVP" wrote:

OK, I figured that the ComboBox11 was a type and should have been
ComboBox1.

I would suggest that you give the comboboxes names that have some meaning to
them.

It also reinforces my believe that your logic needs some work.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Owen" wrote in message
...
Hi Doug

I am going to read further into the Select Case function.

Initially though, i can't understand how the function would determine if
"calcareous" or "carbonate" are selected since nowhere is ComboBox11
(which
contains those values) referenced in the code you provided.

I'll do some more research on this function, but let me know if i am
missing
something simple here.

Thanks again

"Doug Robbins - Word MVP" wrote:

Try

If ActiveDocument.ComboBox26.Text = "CLAY" Then
Select Case ActiveDocument.ComboBox1.Text
Case "calcareous" Or "carbonate"
Selection.GoTo What:=wdGoToBookmark, Name:="Sample6"
Case "Slightly cemented" Or "Moderately cemented" Or "Well
cemented"
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
Case "Very weak" Or "Weak" Or "Moderately weak" Or "Moderately
strong" _
Or "Strong" Or "Very strong" Or "Extremely strong"
Selection.GoTo What:=wdGoToBookmark, Name:="Sample16"
Case Else
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
End Select
End If
With Selection
.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
.Copy
.GoTo What:=wdGoToBookmark, Name:="Result1"
.Paste
End With

I think that your logic might need a bit of work. What about the case
where
ComboBox26.Text "CLAY"

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Owen" wrote in message
...
Hi Macropod

Thanks for the response. You have solved my initial problem. I now have
encountered another problem when trying to extend my code. I have
pasted
the
code below. The problem occurs at the first line in the debugger, where
i
have used the AND and OR statements. I get a message saying "Type
Mismatch".

Any thoughts here?

Thanks again for your time.

Sub test()
If ActiveDocument.ComboBox26.Text = "CLAY" And
ActiveDocument.ComboBox11.Text = "calcareous" Or "carbonate" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample6"
Else
If ActiveDocument.ComboBox26.Text = "CLAY" And
ActiveDocument.ComboBox1.Text = "Slightly cemented" Or "Moderately
cemented"
Or "Well cemented" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
Else
If ActiveDocument.ComboBox26.Text = "CLAY" And
ActiveDocument.ComboBox1.Text = "Very weak" Or "Weak" Or "Moderately
weak"
Or
"Moderately strong" Or "Strong" Or "Very strong" Or "Extremely strong"
Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample16"
Else
If ActiveDocument.ComboBox26.Text = "CLAY" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
End If
End If
End If
End If
With Selection
.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
.Copy
.GoTo What:=wdGoToBookmark, Name:="Result1"
.Paste
End With
End Sub

"macropod" wrote:

Hi Owen,

Try something along the lines of:
Sub test()
If ActiveDocument.ComboBox26.Text = "CLAY" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
Else
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
End If
With Selection
.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
.Copy
.GoTo What:=wdGoToBookmark, Name:="Result1"
.Paste
End With
End Sub

--
Cheers
macropod
[Microsoft MVP - Word]


"Owen" wrote in message
...
I am using an activex control (combobox) in a macro that exists
within
my
word document. I have attached my code below.

The problem is that even when the combobox selection is NOT equal to
CLAY,
the macro still executes the code as if the combobox selection was
CLAY.

Prehaps the "if result =" method is not valid here?

Appreciate any help you can offer.

Sub test()
Dim CB26 As Object
Set CB26 = ActiveDocument.ComboBox26
With CB26
If Result = CLAY Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
Selection.MoveRight unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Selection.Copy
Selection.GoTo What:=wdGoToBookmark, Name:="Result1"
Selection.Paste
Else
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
Selection.MoveRight unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Selection.Copy
Selection.GoTo What:=wdGoToBookmark, Name:="Result1"
Selection.Paste
End If
End With
End Sub





  #9   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Activex Control in Word Document

Try:

If ActiveDocument.ComboBox26.Text = "CLAY" Then
Select Case ActiveDocument.ComboBox1.Text
Case "calcareous", "carbonate"
Selection.GoTo What:=wdGoToBookmark, Name:="Sample6"
Case "Slightly cemented", "Moderately cemented", "Well cemented"
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
Case "Very weak", "Weak", "Moderately weak", "Moderately strong", _
"Strong", "Very strong", "Extremely strong"
Selection.GoTo What:=wdGoToBookmark, Name:="Sample16"
Case Else
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
End Select
End If
With Selection
.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
.Copy
.GoTo What:=wdGoToBookmark, Name:="Result1"
.Paste
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Owen" wrote in message
...
I copied your code however i am now getting a message "Type Mismatch" at
the
third line of code

Case "calcareous" Or "carbonate"

I am using Word 2003, could this have any effect?



"Doug Robbins - Word MVP" wrote:

OK, I figured that the ComboBox11 was a type and should have been
ComboBox1.

I would suggest that you give the comboboxes names that have some meaning
to
them.

It also reinforces my believe that your logic needs some work.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Owen" wrote in message
...
Hi Doug

I am going to read further into the Select Case function.

Initially though, i can't understand how the function would determine
if
"calcareous" or "carbonate" are selected since nowhere is ComboBox11
(which
contains those values) referenced in the code you provided.

I'll do some more research on this function, but let me know if i am
missing
something simple here.

Thanks again

"Doug Robbins - Word MVP" wrote:

Try

If ActiveDocument.ComboBox26.Text = "CLAY" Then
Select Case ActiveDocument.ComboBox1.Text
Case "calcareous" Or "carbonate"
Selection.GoTo What:=wdGoToBookmark, Name:="Sample6"
Case "Slightly cemented" Or "Moderately cemented" Or "Well
cemented"
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
Case "Very weak" Or "Weak" Or "Moderately weak" Or "Moderately
strong" _
Or "Strong" Or "Very strong" Or "Extremely strong"
Selection.GoTo What:=wdGoToBookmark, Name:="Sample16"
Case Else
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
End Select
End If
With Selection
.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
.Copy
.GoTo What:=wdGoToBookmark, Name:="Result1"
.Paste
End With

I think that your logic might need a bit of work. What about the case
where
ComboBox26.Text "CLAY"

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Owen" wrote in message
...
Hi Macropod

Thanks for the response. You have solved my initial problem. I now
have
encountered another problem when trying to extend my code. I have
pasted
the
code below. The problem occurs at the first line in the debugger,
where
i
have used the AND and OR statements. I get a message saying "Type
Mismatch".

Any thoughts here?

Thanks again for your time.

Sub test()
If ActiveDocument.ComboBox26.Text = "CLAY" And
ActiveDocument.ComboBox11.Text = "calcareous" Or "carbonate" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample6"
Else
If ActiveDocument.ComboBox26.Text = "CLAY" And
ActiveDocument.ComboBox1.Text = "Slightly cemented" Or "Moderately
cemented"
Or "Well cemented" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
Else
If ActiveDocument.ComboBox26.Text = "CLAY" And
ActiveDocument.ComboBox1.Text = "Very weak" Or "Weak" Or "Moderately
weak"
Or
"Moderately strong" Or "Strong" Or "Very strong" Or "Extremely
strong"
Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample16"
Else
If ActiveDocument.ComboBox26.Text = "CLAY" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
End If
End If
End If
End If
With Selection
.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
.Copy
.GoTo What:=wdGoToBookmark, Name:="Result1"
.Paste
End With
End Sub

"macropod" wrote:

Hi Owen,

Try something along the lines of:
Sub test()
If ActiveDocument.ComboBox26.Text = "CLAY" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
Else
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
End If
With Selection
.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
.Copy
.GoTo What:=wdGoToBookmark, Name:="Result1"
.Paste
End With
End Sub

--
Cheers
macropod
[Microsoft MVP - Word]


"Owen" wrote in message
...
I am using an activex control (combobox) in a macro that exists
within
my
word document. I have attached my code below.

The problem is that even when the combobox selection is NOT equal
to
CLAY,
the macro still executes the code as if the combobox selection
was
CLAY.

Prehaps the "if result =" method is not valid here?

Appreciate any help you can offer.

Sub test()
Dim CB26 As Object
Set CB26 = ActiveDocument.ComboBox26
With CB26
If Result = CLAY Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
Selection.MoveRight unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Selection.Copy
Selection.GoTo What:=wdGoToBookmark,
Name:="Result1"
Selection.Paste
Else
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
Selection.MoveRight unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Selection.Copy
Selection.GoTo What:=wdGoToBookmark,
Name:="Result1"
Selection.Paste
End If
End With
End Sub






  #10   Report Post  
Posted to microsoft.public.word.docmanagement
owen owen is offline
external usenet poster
 
Posts: 61
Default Activex Control in Word Document

Awesome, that did it.

Thanks so much for your help.

"Doug Robbins - Word MVP" wrote:

Try:

If ActiveDocument.ComboBox26.Text = "CLAY" Then
Select Case ActiveDocument.ComboBox1.Text
Case "calcareous", "carbonate"
Selection.GoTo What:=wdGoToBookmark, Name:="Sample6"
Case "Slightly cemented", "Moderately cemented", "Well cemented"
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
Case "Very weak", "Weak", "Moderately weak", "Moderately strong", _
"Strong", "Very strong", "Extremely strong"
Selection.GoTo What:=wdGoToBookmark, Name:="Sample16"
Case Else
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
End Select
End If
With Selection
.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
.Copy
.GoTo What:=wdGoToBookmark, Name:="Result1"
.Paste
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Owen" wrote in message
...
I copied your code however i am now getting a message "Type Mismatch" at
the
third line of code

Case "calcareous" Or "carbonate"

I am using Word 2003, could this have any effect?



"Doug Robbins - Word MVP" wrote:

OK, I figured that the ComboBox11 was a type and should have been
ComboBox1.

I would suggest that you give the comboboxes names that have some meaning
to
them.

It also reinforces my believe that your logic needs some work.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Owen" wrote in message
...
Hi Doug

I am going to read further into the Select Case function.

Initially though, i can't understand how the function would determine
if
"calcareous" or "carbonate" are selected since nowhere is ComboBox11
(which
contains those values) referenced in the code you provided.

I'll do some more research on this function, but let me know if i am
missing
something simple here.

Thanks again

"Doug Robbins - Word MVP" wrote:

Try

If ActiveDocument.ComboBox26.Text = "CLAY" Then
Select Case ActiveDocument.ComboBox1.Text
Case "calcareous" Or "carbonate"
Selection.GoTo What:=wdGoToBookmark, Name:="Sample6"
Case "Slightly cemented" Or "Moderately cemented" Or "Well
cemented"
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
Case "Very weak" Or "Weak" Or "Moderately weak" Or "Moderately
strong" _
Or "Strong" Or "Very strong" Or "Extremely strong"
Selection.GoTo What:=wdGoToBookmark, Name:="Sample16"
Case Else
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
End Select
End If
With Selection
.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
.Copy
.GoTo What:=wdGoToBookmark, Name:="Result1"
.Paste
End With

I think that your logic might need a bit of work. What about the case
where
ComboBox26.Text "CLAY"

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Owen" wrote in message
...
Hi Macropod

Thanks for the response. You have solved my initial problem. I now
have
encountered another problem when trying to extend my code. I have
pasted
the
code below. The problem occurs at the first line in the debugger,
where
i
have used the AND and OR statements. I get a message saying "Type
Mismatch".

Any thoughts here?

Thanks again for your time.

Sub test()
If ActiveDocument.ComboBox26.Text = "CLAY" And
ActiveDocument.ComboBox11.Text = "calcareous" Or "carbonate" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample6"
Else
If ActiveDocument.ComboBox26.Text = "CLAY" And
ActiveDocument.ComboBox1.Text = "Slightly cemented" Or "Moderately
cemented"
Or "Well cemented" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
Else
If ActiveDocument.ComboBox26.Text = "CLAY" And
ActiveDocument.ComboBox1.Text = "Very weak" Or "Weak" Or "Moderately
weak"
Or
"Moderately strong" Or "Strong" Or "Very strong" Or "Extremely
strong"
Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample16"
Else
If ActiveDocument.ComboBox26.Text = "CLAY" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
End If
End If
End If
End If
With Selection
.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
.Copy
.GoTo What:=wdGoToBookmark, Name:="Result1"
.Paste
End With
End Sub

"macropod" wrote:

Hi Owen,

Try something along the lines of:
Sub test()
If ActiveDocument.ComboBox26.Text = "CLAY" Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
Else
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
End If
With Selection
.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
.Copy
.GoTo What:=wdGoToBookmark, Name:="Result1"
.Paste
End With
End Sub

--
Cheers
macropod
[Microsoft MVP - Word]


"Owen" wrote in message
...
I am using an activex control (combobox) in a macro that exists
within
my
word document. I have attached my code below.

The problem is that even when the combobox selection is NOT equal
to
CLAY,
the macro still executes the code as if the combobox selection
was
CLAY.

Prehaps the "if result =" method is not valid here?

Appreciate any help you can offer.

Sub test()
Dim CB26 As Object
Set CB26 = ActiveDocument.ComboBox26
With CB26
If Result = CLAY Then
Selection.GoTo What:=wdGoToBookmark, Name:="Sample1"
Selection.MoveRight unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Selection.Copy
Selection.GoTo What:=wdGoToBookmark,
Name:="Result1"
Selection.Paste
Else
Selection.GoTo What:=wdGoToBookmark, Name:="Sample11"
Selection.MoveRight unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Selection.Copy
Selection.GoTo What:=wdGoToBookmark,
Name:="Result1"
Selection.Paste
End If
End With
End Sub







Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I enable ActiveX control for discussion groups alabue1973 New Users 3 June 2nd 08 04:24 AM
How do I automatically activate ActiveX control? Ruth Microsoft Word Help 1 July 11th 06 11:55 AM
ActiveX Control for Word Demos Penny Microsoft Word Help 0 October 20th 05 10:59 PM
Is there a Microsoft Word ActiveX Control for the Web? Patrick Niland Microsoft Word Help 0 October 3rd 05 11:29 AM
Mysterious ActiveX control in world document. Walter R. Microsoft Word Help 0 March 6th 05 05:43 PM


All times are GMT +1. The time now is 01:55 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"