Macro to transfer info from Excel to Words envelope Dialog box.


E

EWASHI5279

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
 
Ad

Advertisements

D

Dick Kusleika

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
 

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