Probably Incredibly dumb newb. question

T

The Loeki

Hello,

I don't do VBA usually. However, I must now accomplish a seemingly very
simple task, but I can't for the life of me figure out how.

Upon activation of the macro, I want Word (XP) to insert a textbox (not
a Form TextBox, where the bulk of my Google queries end up, but just as
in Insert>Textbox) fill it with plain text and assign certain
properties to it.

This is probably just a few lines of code, however I have no clue,
since, on the rare occasion I've needed to do VBA, I just used the
macro-recorder and worked my way around from there.
The macro-recorder however doesn't record inserting textboxes :(

Please assist? Thanks loads in advance!

Loeki
 
T

The Loeki

Well, that's a bit of my problem, I don't. The only writing I'm good at
is a bit of basic batching ;-)

I'm not developing, I'm just /kinda/ maintaining, and currently looking
for this single feature to solve a small problem we're having with
automatic numbering.

Chances are that I won't touch the VBA codes again in months, except
(like right now) for some very minor adjustments (margin settings &
stuff).
 
T

The Loeki

Right... My progress so far:

Sub Bullets()
'
' Alternative Bullets
' 16-03-2005
'

ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, 0, 0,
10, 15).Select

'ActiveDocument.Paragraphs(1).Range

With Selection.ShapeRange
..TextFrame.TextRange.Text = "./."
..Fill.Visible = msoFalse
..Line.Visible = msoFalse
..TextFrame.MarginLeft = 0#
..TextFrame.MarginRight = 0#
..TextFrame.MarginTop = 0#
..TextFrame.MarginBottom = 0#
..TextFrame.WordWrap = False
..RelativeHorizontalPosition = wdRelativeHorizontalPositionColumn
..RelativeVerticalPosition = wdRelativeVerticalPositionLine
..Left = CentimetersToPoints(-1.5)
..Top = CentimetersToPoints(0)
End With

End Sub

This code has 2 downsides, for which I humbly again ask help :)
-The textbox can be anchored using ActiveDocument.Paragraphs().Range,
but I just want it to anchor at the CURRENT paragraph.
-The textbox stays selected, how do I return te cursor to it's previous
position?

Thanks in advance
 
T

The Loeki

Sub Bullets()
'
' Alternative Bullets
' 16-03-2005
'

ActiveDocument.Bookmarks.Add ("BULLETMARKFIETSBEL")
ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, 0, 0,
10, 15, ActiveDocument.Bookmarks("BULLETMARKFIETSBEL").Range).Select

With Selection.ShapeRange
..TextFrame.TextRange.Text = "./."
..Fill.Visible = msoFalse
..Line.Visible = msoFalse
..TextFrame.MarginLeft = 0#
..TextFrame.MarginRight = 0#
..TextFrame.MarginTop = 0#
..TextFrame.MarginBottom = 0#
..TextFrame.WordWrap = False
..RelativeHorizontalPosition = wdRelativeHorizontalPositionColumn
..RelativeVerticalPosition = wdRelativeVerticalPositionLine
..Left = CentimetersToPoints(-1.5)
..Top = CentimetersToPoints(0)
..LockAnchor = True
End With

Selection.GoTo What:=wdGoToBookmark, Name:="BULLETMARKFIETSBEL"
ActiveDocument.Bookmarks("Bullet").Delete
End Sub


Thanks anyway
 

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