AnswerBun.com

VB.NET: Inserting text right after the end of the paragraph

Stack Overflow Asked by Tora Garo on December 11, 2020

My goal is to create a word doc where in each letter has different fonts. Fonts will be randomly selected. Code seems working but the only problem is that I can’t get the letters append right after the previous string. It keeps making new paragraph for each letter.

            wp = wd.Content.Paragraphs.Add
            wp.selection.Font.Name = font
            wp.selection.TypeText = letter

Here’s the result

Image 1

Image 2

One Answer

You probably want to use the selection property over Range.

Try replacing

wp.Range.Font.Name = font
wp.Range.Text = letter

with

wp.Selection.font.Name = font
wp.Selection.TypeText letter

Selection will be the current location of the cursor.

I'm not exactly sure of your intent with wp.Range.InsertParagraphAfter(), but I don't believe it's necessary to be in the For Each . . . Next loop.

Correct answer by K.Dᴀᴠɪs on December 11, 2020

Add your own answers!

Related Questions

Remove web-inspector-hide-shortcut

0  Asked on January 9, 2021 by dumi-padureanu

   

Pandas – Lambda inside apply to return a row

1  Asked on January 9, 2021 by marcio

         

Unclear webhook eventNotification documentation

1  Asked on January 9, 2021 by nolan-aguirre

 

c – Access not within mapped region error

0  Asked on January 9, 2021 by rhcp_lean

     

How to reduce committed memory usage in Java

1  Asked on January 9, 2021 by simon-hu

   

mutool / mulib edit text (with a c programm)

1  Asked on January 9, 2021 by atticus

   

Running browsermob with selenium grid on docker

2  Asked on January 8, 2021 by eduardoreynoso

         

How do I exclude a repeated click event?

2  Asked on January 8, 2021 by jessy

   

handling promises using await and async

2  Asked on January 8, 2021 by jass-preet

   

How to compare data from the same column in a dataframe (Pandas)

4  Asked on January 8, 2021 by abraham-arreola

       

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP