![]() |
Copying Cell data and pasting into word document?
Is it possible in VBA to copy named range data and paste it in to new word document?, I intend using a command button to start the code where for arguments sake Range("A1") will have a name selected from a list which will be the name of the named range, on click of the button copy and paste the named range data (values only!) in to a newly opened word document, it doesnt matter if it is pasted in to the default position (where the cursor starts flashing) when you first open word. Any ideas? Regards, Simon -- Simon Lloyd ------------------------------------------------------------------------ Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708 View this thread: http://www.excelforum.com/showthread...hreadid=549029 |
Copying Cell data and pasting into word document?
Dim appwd As Object On Error GoTo notloaded Set appwd = GetObject(, "Word.Application") notloaded: If Err.Number = 429 Then Set appwd = CreateObject("Word.Application") End If appwd.Visible = True On Error GoTo 0 With appwd .typetext range("whatever").value end with Simon Lloyd wrote: Is it possible in VBA to copy named range data and paste it in to new word document?, I intend using a command button to start the code where for arguments sake Range("A1") will have a name selected from a list which will be the name of the named range, on click of the button copy and paste the named range data (values only!) in to a newly opened word document, it doesnt matter if it is pasted in to the default position (where the cursor starts flashing) when you first open word. Any ideas? Regards, Simon -- Simon Lloyd ------------------------------------------------------------------------ Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708 View this thread: http://www.excelforum.com/showthread...hreadid=549029 |
Copying Cell data and pasting into word document?
Hi Aidan thanks for the reply, i tried running the code in a seperat module, and got the error "run time error '438' Object doesn't suppor this property or method" Any ideas why this might be?, the code opened the Word window but n document (no blank page). Regards, Simo -- Simon Lloy ----------------------------------------------------------------------- Simon Lloyd's Profile: http://www.excelforum.com/member.php...nfo&userid=670 View this thread: http://www.excelforum.com/showthread.php?threadid=54902 |
Copying Cell data and pasting into word document?
Sorry about that - I'm used to working with open instances of Word, and
loading templates, and then using one cell at a time with bookmarks in the template - revised and TESTED code is Dim appwd As Object On Error GoTo notloaded Set appwd = GetObject(, "Word.Application") notloaded: If Err.Number = 429 Then Set appwd = CreateObject("Word.Application") End If appwd.Visible = True On Error GoTo 0 With appwd '.documents.Add Range("A1:B2").Copy 'replace A1:B2 with the range you want! .Selection.Paste End With Simon Lloyd wrote: Hi Aidan thanks for the reply, i tried running the code in a seperate module, and got the error "run time error '438' Object doesn't support this property or method" Any ideas why this might be?, the code opened the Word window but no document (no blank page). Regards, Simon -- Simon Lloyd ------------------------------------------------------------------------ Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708 View this thread: http://www.excelforum.com/showthread...hreadid=549029 |
Copying Cell data and pasting into word document?
Thanks Aidan, worked a treat! Regards, Simon -- Simon Lloyd ------------------------------------------------------------------------ Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708 View this thread: http://www.excelforum.com/showthread...hreadid=549029 |
All times are GMT +1. The time now is 03:40 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com