Sub cmdcopytoword_Click()
Dim i As Long
Dim arr
Dim strRange As String
strRange = Range("rpp").Cells(1)
If Range("rpp").Cells.Count 1 Then
arr = Range("rpp")
For i = 2 To UBound(arr)
strRange = strRange & "," & arr(i, 1)
Next
End If
Cells(1) = strRange
Cells(1).Copy
' open Word
Dim appWD As Object
Set appWD = CreateObject("Word.Application")
appWD.Visible = True
'open a new document in Word
appWD.Documents.Add DocumentType:=wdNewBlankDocument
' paste from clipboard
appWD.Selection.Paste
With appWD.ActiveDocument
SaveAs "C:\autogenr.doc"
Close
End With
End Sub
RBS
"roshinpp_77"
wrote in message
...
Hi friend,
This is my macro for copying a range named "rpp" to a new word doc
generated in c:\autogenr.doc.
My input is:
COL: C
1001
1002
1003
1004
1005
1006
1007
`my output in word has to be:
1001,1002,1003,1004,1005,1006,1007 etc..till the end
Below macro will copy the entire range as it is (as table) from excel
to doc.
Sub cmdcopytoword_Click()
'copy sheet to clipboard
Range("rpp").Select
Selection.Copy
Range("B3").Select
' open Word
Dim appWD As Object
Set appWD = CreateObject("Word.Application")
appWD.Visible = True
'open a new document in Word
appWD.Documents.Add DocumentType:=wdNewBlankDocument
' paste from clipboard
appWD.Selection.Paste
With appWD.ActiveDocument
SaveAs "C:\autogenr.doc"
Close
End With
--
roshinpp_77
------------------------------------------------------------------------
roshinpp_77's Profile:
http://www.excelforum.com/member.php...o&userid=34924
View this thread: http://www.excelforum.com/showthread...hreadid=562026