Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Word VBA Variables

Status
Not open for further replies.

ShaneBrennan

Programmer
Joined
May 19, 1999
Messages
198
Location
GB
I want a very simple program that will accept the name of a user via a InputBox then display the input into the current document at the current cursor position.

Does anyone know how to finish off the following Macro to achieve this?

Thanks in advance for any help given

Shane Brennan

Private Sub test()

Username= InputBox("What is your username")

** How the devil do I display the contents of Username?

End Sub

Shane Brennan

'-----------------------

' Emails: shanebrennan@postmaster.co.uk


 
The tutorial was good and helped quite a bit and has given me a good few examples for future documents.

Yes I want to put information into the document, but at the current cursor position not at a bookmark.

The following WILL place the input at the bookmark's position, but I just simply want to paste the contents of the variable to the current cursor position.

Sub test()

UserName = InputBox("Please Enter your username")
ActiveDocument.Bookmarks("bmkUsername").Range.Text = UserName
End Sub

I've used:

ThisDocument.Content.InsertAfter (UserName)
ThisDocument.Content.InsertBefore (UserName)

But they place text at the beginning or end of the document - not in the current position.

Thanks again DreamBoat - but it was not what I was looking for for this task - but the link you sent me was fantastic.



Shane Brennan

'-----------------------

' Emails: shanebrennan@postmaster.co.uk


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top