[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How programmatically insert text into word document?

Posted on 2004-10-13
7
Medium Priority
?
1,004 Views
Last Modified: 2012-08-13
I need programmatically insert text into word document and it should be placed in particular location (say 30 points from top and 50 points from left). I can not consider TextBox, it must be "regular" string.
Is there any way to accomplish this?

TIA  
0
Comment
Question by:MTchary
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 12304494
Are you gathering the information to be placed there from a VBA user form?  If so, you could do something like this:

    If frmPB.TextBox2.Text <> "" Then
        Selection.Bookmarks.Add Name:="address", Range:=Selection.Range
        Selection.Style = "Address"
        Selection.TypeText frmPB.TextBox3.Text
        Selection.TypeParagraph
    End If
    If frmPB.TextBox4.Text <> "" Then
        Selection.Style = "Salutation"
        Selection.TypeText frmPB.TextBox4.Text
    End If

0
 
LVL 11

Expert Comment

by:Steiner
ID: 12305451
Since Word is "paragraph oriented" it may be difficult to have words "floating" in your document without using a textfield.
Maybe you can layout the document and place bookmarks where you later want the text to go. So place a bookmark just 30 points from top and 50 points from left by inserting paragraphs, tabs and spaces.
Now you just need to use:

ActiveDocument.Bookmarks("YourBookmarkName").Range.Text = myString
0
 

Author Comment

by:MTchary
ID: 12307364
It seems to me that I can use only 'Paragraph' and 'Tab' to position Text in a Document at defined location. But, I think, it will be hard to place text in particular position because 'Paragraph' has constant height and 'Tab' has its constant length. Or may be exist a way to manage those value (height & length)?

TIA
0
On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 12310004
How about Insert, Field, Advance?
0
 
LVL 11

Accepted Solution

by:
Steiner earned 195 total points
ID: 12336443
Well, the height of an paragraph is determined by the font size and the space between paragraphs (Format - Paragraph). The tab width you can set by using the horzontal ruler or using then menu Format - Paragraph - Tab.
0
 
LVL 37

Assisted Solution

by:Joanne M. Orzech
Joanne M. Orzech earned 180 total points
ID: 12375537
Spacing between paragraphs can be changed by selecting the paragraph and go to Format, Paragraph, Line Spacing, and change it to something less....if you select "exactly" 8 pt. or something - as Steiner said - it depends on the size of your font.

Hope that helps
0
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 12380697
Thank you!  Glad it's working for you.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question