transforming excel cell contents in word document, with coma separated.

  • Thread starter Thread starter roshinpp_77
  • Start date Start date
R

roshinpp_77

transforming excel cell contents in word docum:confused: ent, with coma
separated.

Hi members,
It will be nice if anybody could tell me how to copy cell
contents..(eg: From A1,A2,A3,A4,A5 etc..downwards )to word document in
the format contents of A1,A2,A3,A4,a5.

I know how to transform a certain range of cells from excel to word in
the same(ie.as tables itself) form, but how to change the format with
coma separation.

TIA

Roshin
 
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
 
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" <[email protected]>
wrote in message
news:[email protected]...
 
Thanks RB Smissaert ,
but still another problem arised in between.
Your modification is working perfectly for small numbers.But for me
each cell is a 6 digit number and it is going for 50 to 60 cells.ie.

100001
122200
233333
133444
345566
......
...
upto 50 lines
So when i open the word file i am getting the output as
"#############".
Even in the cell(1) of excel sheet i am not able to set a correct
format that shows me 100001,122200,......

Your suggestion is awaited,

TIA
Roshin
 
Thanks friend..i got it.
Instead of Cells(1), i gave Cells(1,1) and now its working perfectly.

Once again
Thanks a lot.

regards
Roshi
 
Back
Top