Unable To insert Line Break when selection is in TextBox

A

Anita

hi ,

i am using Word Object Model to insert line break at selection using below
statement:

applicationObject.Selection.InsertBreak(ref BreakType)

where BreakType is defined as

object BreakType = MSword.WdBreakType.wdLineBreak;

i get an COMException "Command Not available" whenever the current selection
is with textBox. (inserted using Insert->TextBox)

is anyone aware of alternate way of doing the same?

Thanks and Regards,
Anita.
 
J

Jay Freedman

hi ,

i am using Word Object Model to insert line break at selection using below
statement:

applicationObject.Selection.InsertBreak(ref BreakType)

where BreakType is defined as

object BreakType = MSword.WdBreakType.wdLineBreak;

i get an COMException "Command Not available" whenever the current selection
is with textBox. (inserted using Insert->TextBox)

is anyone aware of alternate way of doing the same?

Thanks and Regards,
Anita.

If you try this directly in VBA instead of automating Word from outside, the
error that occurs is "Run-time error '4605': This method or property is not
available because the object refers to a text box."

However, this works in VBA and might work for you:

Selection.TypeText Chr(11)
 

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