Exporting to excel csv and how to set the cell to wrap text

N

Norman Fritag

Hi there,

1) I is there a more elegant way, more professionally way this export could
done, as I have written some code for the first time?
2) who could I wrap text cell a1 a3 via code ?
3) is there a tutorial whereas I refresh my knowledge?

and here goes the code

Regards

Norman


'Start of snippet

Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim strcount, strdate, Strnewfile, strCSVFILE As String

Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = False
Set xlBook = xlApp.Workbooks.Open(filename:=strCSVFILE)

Set xlSheet = xlBook.ActiveSheet

Set xlSelection = xlSheet.Range(xlSheet.Cells(1, 1), xlSheet.Cells(1,
1).End(xlToRight))

Set xlSelection = xlSheet.Range("A1")
xlSheet.Range("A1").Value = "Report Coverage" _
& " National Program" _
& " Results for Period 4th August - " & strdate & " " & Format(Date,
"mmmm yyyy") & "."


Set xlSelection = xlSheet.Range("A3")
xlSheet.Range("A3").Value = "This report reflects data received by the "
_
& "xxxxxxxx department" & Format(Now(), "h ampm") _
& " " & Format(Now(), "dddd") & strdate & " " & Format(Now(), "mmmm,
yyyy") & "." & _
" Data is provisional and subject to ongoing revision and review."

Set xlSelection = xlSheet.Range("A5")
xlSheet.Range("A5").Value = "AHS"
Set xlSelection = xlSheet.Range("B5")
xlSheet.Range("B5").Value = "Total Number of Targetgroup" & _
" Aged 15 - 19 Year Group"
Set xlSelection = xlSheet.Range("C5")
xlSheet.Range("C5").Value = "Total Number of Targetgroup" & _
" of Other Ages"
Set xlSelection = xlSheet.Range("D5")
xlSheet.Range("D5").Value = "Total Number of Targetgroup"
' end of snippet
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top