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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB and MS-Word

Status
Not open for further replies.

dcusick

Technical User
Aug 9, 2000
271
US
I have an application that tracks information in a database. If a user wants to add comments, I have them push a button on the main form. That opens up a pre-existing file in Word and allows the user to enter in any appropriate comments. Everything works fine except the users want each comment Time and User stamped as they add them. For instance if User A adds "Made a call to home" at 12:00 then they want the log file to show "12:00:00 pm - Made a call to home (User A)". I can't figure out how to stamp a line in a Word Document only after it is updated. Is there any way to do this? or will this have to be done manually? Any help would be greatly appreciated.

Doug
 
Doug,

Rather than having them type directly into word, why don't you also provide a text box for them to enter their comments. Then you don't even have to visually open word for them to enter the information. you can just create an invisible instance of it and everything will be passed through from your application.

Here's some code to get you started:

--------------------------------------------
Dim wdCheckList As New Word.Application

With wdCheckList
'Hide word from the user
.Visible = False
.Documents.Add "C:\TimeStamp.doc"
'select all text in the document
.ActiveDocument.Select
'move the cursor to the end of the selected text
'(the end of the document)
.Selection.MoveDown
'append the time stamp and text from a text box
.Selection.TypeText Now() & " - " & Text1.Text
.Selection.TypeParagraph
End With

'Put your save and cleanup code here....

---------------------------------------

Hope this helps.
~Kevin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top