Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default 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


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying a doc from Excel and pasting it into Word. KC New Users to Excel 2 March 14th 09 08:39 PM
Prevent invalid data when pasting from Word directly onto cell? Stacey Excel Discussion (Misc queries) 3 September 26th 08 11:03 PM
copying from word and pasting into excel nims[_4_] Excel Programming 1 August 24th 05 08:24 PM
Excel - Word: Problems copying/pasting shapes Nick Hebb Excel Programming 1 June 17th 05 09:55 PM
VB automated pasting of Excel range into Word document ardvk Excel Programming 3 January 8th 05 06:09 AM


All times are GMT +1. The time now is 03:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"