Delete and Cut fails when programming MS Word if Word not visible

Delete and Cut fails when programming MS Word if Word not visible

Post by David A. Wrigh » Wed, 14 Feb 2001 08:47:00



Hi,

When programming Word from a VB application the following methods fail if
the application is not visible . They work fine if it is visible :

    WordObject.Selection.Delete 'Unit:=wdCharacter, Count:=1

    and

    WordObject.Selection.Cut

Word.Selection.TypeBackspace works but can't be used to delete a section. As
a consequence I am having to make the document visible before deleting
anything.

Any suggestions would be gratefully received.

Thanks in advance

David A. Wright

 
 
 

Delete and Cut fails when programming MS Word if Word not visible

Post by Russell Boy » Wed, 14 Feb 2001 08:14:16


Something else you could try, David:

WordObject.Selection.Sections(1).Range.Delete

This will delete the section break if the cursor is just before it or the
break is selected

I haven't tested it under your circumstances, though!

Russell

___________________________________


>Hi,

>When programming Word from a VB application the following methods fail if
>the application is not visible . They work fine if it is visible :

>    WordObject.Selection.Delete 'Unit:=wdCharacter, Count:=1

>    and

>    WordObject.Selection.Cut

>Word.Selection.TypeBackspace works but can't be used to delete a section.
As
>a consequence I am having to make the document visible before deleting
>anything.

>Any suggestions would be gratefully received.

>Thanks in advance

>David A. Wright


 
 
 

Delete and Cut fails when programming MS Word if Word not visible

Post by David A. Wrigh » Tue, 20 Feb 2001 10:17:16


Thanks Russel for your reply.

I was not aware of that syntax so thank you.

Unfortunately however it did not work in a master document when it was not
active or visible.

I managed to get the Word.Selection.TypeBackspace to work to delete a
section when the section and the section break were all selected at once.

I have not been able to determine if this is a Microsoft problem with code
which simply does not work when a master document and word object is not
active or visible or whether it is a Master Document problem.

Thanks anyway

David


> Something else you could try, David:

> WordObject.Selection.Sections(1).Range.Delete

> This will delete the section break if the cursor is just before it or the
> break is selected

> I haven't tested it under your circumstances, though!

> Russell

> ___________________________________

> >Hi,

> >When programming Word from a VB application the following methods fail if
> >the application is not visible . They work fine if it is visible :

> >    WordObject.Selection.Delete 'Unit:=wdCharacter, Count:=1

> >    and

> >    WordObject.Selection.Cut

> >Word.Selection.TypeBackspace works but can't be used to delete a section.
> As
> >a consequence I am having to make the document visible before deleting
> >anything.

> >Any suggestions would be gratefully received.

> >Thanks in advance

> >David A. Wright

 
 
 

Delete and Cut fails when programming MS Word if Word not visible

Post by Russell Boy » Thu, 22 Feb 2001 11:42:48


Ummm... You are aware of the problems with using Master docs?

This could have something to do with it. Do a search on Master docs at the
MVP site - if this is news to you.

Russell

http://www.mvps.org/word/


>Thanks Russel for your reply.

>I was not aware of that syntax so thank you.

>Unfortunately however it did not work in a master document when it was not
>active or visible.

>I managed to get the Word.Selection.TypeBackspace to work to delete a
>section when the section and the section break were all selected at once.

>I have not been able to determine if this is a Microsoft problem with code
>which simply does not work when a master document and word object is not
>active or visible or whether it is a Master Document problem.

>Thanks anyway

>David



>> Something else you could try, David:

>> WordObject.Selection.Sections(1).Range.Delete

>> This will delete the section break if the cursor is just before it or the
>> break is selected

>> I haven't tested it under your circumstances, though!

>> Russell

>> ___________________________________

>> >Hi,

>> >When programming Word from a VB application the following methods fail
if
>> >the application is not visible . They work fine if it is visible :

>> >    WordObject.Selection.Delete 'Unit:=wdCharacter, Count:=1

>> >    and

>> >    WordObject.Selection.Cut

>> >Word.Selection.TypeBackspace works but can't be used to delete a
section.
>> As
>> >a consequence I am having to make the document visible before deleting
>> >anything.

>> >Any suggestions would be gratefully received.

>> >Thanks in advance

>> >David A. Wright