Write to Word Document from Excel VBA Help Needed

G

Guest

I have written the VBA to loop through a column on an Excel spreadsheet and
if the font description is "Script", I want to write the font name, the
alphabet (formatted in the font), and some other detail to a Word Document.
I have been able to create a new Word document, and I can save it and close
it from the Excel VBA, but I can NOT figure out how to write the information
described above to the Word document.

I know Excel VBA, but (obviously), I don't know Word VBA. I am using
version 2003 on Windows XP platform.

I would really appreaciate any help you could provide.

Thanks, Judy
 
H

Helmut Weber

Hi Judy,

see:
http://word.mvps.org/faqs/interdev/controlwordfromxl.htm
http://word.mvps.org/faqs/interdev/EarlyvsLateBinding.htm

plus have a look at this one:

Private Sub Test0000()
Dim oWrd As Word.Application
Dim oDcm As Word.Document
Dim fntName As String

fntName = activecell.Font.Name

On Error Resume Next
Set oWrd = GetObject(, "Word.application")
If Err Then
Set oWrd = New Word.Application
End If
oWrd.Visible = True
Set oDcm = oWrd.Documents.Add
oDcm.Range.InsertBefore "abcdefghi" & Chr(13)
oDcm.Range.Paragraphs(1).Range.Font.Name = "Arial"
' ....... some more

End Sub

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

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