![]() |
Word and Excel
I have an excel spreadsheet and would like to create a "button" which would
trigger a form letter (in word) to be printed with select information in the excel file. How do I do that? |
You have to open vba (ALT+F11) and paste the next code :
Public Function CoppySelectionToWord() Dim WrdAPP As Object ' Declare variable to hold the reference. Set WrdAPP = CreateObject("Word.application") 'set variable = to word application Selection.Copy 'coppy the selection to clipboard WrdAPP.Visible = True 'make word visible WrdAPP.documents.Add 'create new document in word WrdAPP.Selection.Paste 'paste the selection in word Set WrdAPP = Nothing 'release the variable End Function Then in excel itself you link a button to this code. problem solved ;o) "jhilger" wrote: I have an excel spreadsheet and would like to create a "button" which would trigger a form letter (in word) to be printed with select information in the excel file. How do I do that? |
Thank you for your assistance. When I hit alt + F11, it comes up with a
blank form. What do I bring up to paste this into. I am a novice and have not used VB before. Thanks. "MrT" wrote: You have to open vba (ALT+F11) and paste the next code : Public Function CoppySelectionToWord() Dim WrdAPP As Object ' Declare variable to hold the reference. Set WrdAPP = CreateObject("Word.application") 'set variable = to word application Selection.Copy 'coppy the selection to clipboard WrdAPP.Visible = True 'make word visible WrdAPP.documents.Add 'create new document in word WrdAPP.Selection.Paste 'paste the selection in word Set WrdAPP = Nothing 'release the variable End Function Then in excel itself you link a button to this code. problem solved ;o) "jhilger" wrote: I have an excel spreadsheet and would like to create a "button" which would trigger a form letter (in word) to be printed with select information in the excel file. How do I do that? |
All times are GMT +1. The time now is 08:34 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com