write to word

R

RobcPettit

Hi, Im using streamwriter to write to notepad or word. No problems
with this. Is it possible to write to either notpad or word, while the
document is open, and the data to update as its written. At the
momment notepad has to be closed, saved and reopened to see the data.
Word doesnt allow me to write to it whilst its open.
Regards Robert
 
G

Guest

Here's some code that someone probably provided to me to copy comments out of
Excel into Word. You should be able to extract something from that for
your purposes:


Sub CopyCommentsToWord()

Dim cmt As Comment
Dim WdApp As Object
Dim aWS As Worksheet

On Error Resume Next
Set WdApp = GetObject(, "Word.Application")
If Err.Number <> 0 Then
Err.Clear
Set WdApp = CreateObject("Word.Application")
End If
Debug.Print "after err.number"

With WdApp
.Visible = True
.Documents.Add DocumentType:=0
For Each aWS In ActiveWorkbook.Worksheets
For Each cmt In aWS.Comments
.Selection.TypeText cmt.Parent.Address _
& vbTab & cmt.text
.Selection.TypeParagraph
Next

Next aWS
End With
Set WdApp = Nothing

End Sub
 

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