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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Norman Fritag

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

    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.Applicati on
    Dim xlBook As Excel.Workbook
    Dim xlSheet As Excel.Worksheet
    Dim strcount, strdate, Strnewfile, strCSVFILE As String

    Set xlApp = CreateObject("E xcel.Applicatio n")
    xlApp.Visible = False
    Set xlBook = xlApp.Workbooks .Open(filename: =strCSVFILE)

    Set xlSheet = xlBook.ActiveSh eet

    Set xlSelection = xlSheet.Range(x lSheet.Cells(1, 1), xlSheet.Cells(1 ,
    1).End(xlToRigh t))

    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



Working...