View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dick Kusleika Dick Kusleika is offline
external usenet poster
 
Posts: 179
Default Macro to transfer info from Excel to Words envelope Dialog box.

Eddie

This is probably the worst Word programming ever, but it works. Set a
reference (VBE - Tools - References) to the Microsoft Word x.x Object
Library and run this macro. It assumes that your address is in A1:A3.

Sub MakeEnvelope()

Dim wdApp As Word.Application
Dim wdDoc As Word.Document

Set wdApp = New Word.Application
Set wdDoc = wdApp.Documents.Add

wdApp.Visible = True

wdApp.Selection.Text = Range("A1").Text
wdDoc.Paragraphs.Add
wdDoc.Range(wdDoc.Characters.Count - 1, wdDoc.Characters.Count).Select
wdApp.Selection.Text = Range("a2").Text
wdDoc.Paragraphs.Add
wdDoc.Range(wdDoc.Characters.Count - 1, wdDoc.Characters.Count).Select
wdApp.Selection.Text = Range("a3").Text

wdDoc.Range(0, wdDoc.Characters.Count).Select

wdApp.CommandBars.FindControl(, 794).Execute


End Sub

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"EWASHI5279" wrote in message
...
I have a form letter that I send out regularly. I put the form letter in
Excel to manipulate the Numbers (in cells)and margins better.

My problem is I also print envelopes to go with these letters, but I
can only copy and paste from Excel to the Word envelope dialog box.

I would like to be able to click a button and the Word dialog box comes
up with the address in it.

Thanks for any help you can provide.

Eddie Washington