Access TextBox in Macro

J

Jeri

I have an AutoText entry that is text in a text box. I have a macro that
will insert that AutoText entry. I need to be able to programmatically get
into that text box and insert a date field, but can't figure out how to do
this.

Thanks in advance for any assistance.
 
D

David Horowitz

It depends on exactly how your code works. If you post it, it might help.
It might be something like:
Selection.ShapeRange(1).TextFrame.TextRange.Text
or it might be
ActiveDocument.Shapes(1)/TextFrame.TextRange.Text
It depends on whether your textbox is selected, how many there are in the
document, etc. Basically it sounds like you need to get from the Selection
to your Textbox...
 
J

Jeri

David ~ Thank you for your response. Keep in mind that I am a complete
newbie when it comes to vba. The macro that I have was "recorded", but here
is the code it created:

Sub HMInsertDraftGray()
'
' HMInsertDraftGray Macro
' Inserts HM Gray Draft Stamp
'
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Application.DisplayAutoCompleteTips = True
NormalTemplate.AutoTextEntries("HMGrayDraft").Insert Where:=Selection. _
Range, RichText:=True
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub

The macro goes into the document header and inserts the AutoText entry then
leaves the document header.

What I would ultimately like for the macro to do is to insert the AutoText
entry called "HMGrayDraft" and then go into the text box that contains the
AutoText entry and find the bookmark called DraftDate and insert a date that
looks like this 3/11/2009 11:00 AM and asks the user if the date should be
inserted as a code (updates automatically) or text (static). If I can't get
it to prompt the user, I could always do two subs one for each date type and
add both options to a fly out menu.

Hope this helps! Again, thank you for your assistance.
 

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