ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to transfer info from Excel to Words envelope Dialog box. (https://www.excelbanter.com/excel-programming/275436-macro-transfer-info-excel-words-envelope-dialog-box.html)

EWASHI5279

Macro to transfer info from Excel to Words envelope Dialog box.
 
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

Dick Kusleika

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





All times are GMT +1. The time now is 10:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com