Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Positioning text in Word
Message
De
15/06/2005 05:06:02
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
14/06/2005 16:37:59
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
01023275
Message ID:
01023367
Vues:
11
>We are looking for a way to precisely position small bits of text on a page using the Word.Application object. Trying to record a macro, I was astonished and highly annoyed to find out that the Insert Text Box menu item was ignored whenever a macro was being recorded. I haven't been able to Google my way to an answer. Advancing downward with carriage returns in tiny fonts is possible, but there must be a better way.

Randy,
To add a textbox use AddTextBox method of Shapes collection. ie:
#Define msoTextOrientationHorizontal  1
#Define msoTextOrientationHorizontalRotatedFarEast  6
#Define msoTextOrientationMixed  -2
#Define msoTextOrientationUpward  2
#Define msoTextOrientationVertical  5
#Define msoTextOrientationVerticalFarEast  4

oWord = Createobject('Word.Application')
With oWord
  .Documents.Add
  lnLeft = .InchesToPoints( 2 )
  lnTop  = .InchesToPoints( 5 )
  lnWidth = .InchesToPoints( 4 )
  lnHeight = .InchesToPoints( 0.5 )
  With .ActiveDocument.Shapes.AddTextBox(msoTextOrientationHorizontal, ;
      m.lnLeft,m.lnTop,m.lnWidth,m.lnHeight)
    .TextFrame.TextRange = "This is textbox 1"
    * Precise positioning of text with textbox only
    .Line.Visible = .F. && No line
    .TextFrame.MarginLeft = 0
    .TextFrame.MarginTop   = 0
  Endwith

  * Add 2nd textbox below first - text vertical
  lnTop  = .InchesToPoints( 6 )
  With .ActiveDocument.Shapes.AddTextBox(msoTextOrientationVertical,;
      m.lnLeft,m.lnTop,m.lnWidth,m.lnHeight)
    .TextFrame.TextRange = "This is textbox 2"
    .Line.ForeColor.Rgb = Rgb(255,0,0)
  Endwith
  .Visible = .T.
Endwith
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform