In a VB6 database application, I have several options for outputting information to an Excel worksheet. I've got it to the point where it neatly outputs column headers (and bolds them), pastes all the records under them and puts a report title on the first row. There's two more things I want to do with them, though, and I'm not sure if it's possible from VB and if so, what command to use.
1) Right now I put the report title simply on the first row, using:
Set xlsApp = new Excel.Application
With xlsApp
.Visible = true
.Workbooks.Add
.Cells(1,1).Value = "REPORT TITLE"
.Cells(1,1).Font.Bold = True
(after which I add the column headers and the actual records with more .Cells(X,X).Value statements in a loop.)
(...)
(...)
End With
The user would like to be able to sort the columns after output, though, and the report title is getting in the way of this. She's asked me to have the application put it in the sheet's header instead of on the first row. Is this possible from VB and if so which command would I use?
2) In one of the columns I output, I'd like to align the text to the right. I'm looking for a command along the lines of "xlsapp.Cells(X,X).Align = Right" or such which I could then use in a loop; or alternatively a command that affects the entire column at once. Is there such a command and what's the proper syntax for it?
Thanks in advance!
"Much that I bound, I could not free. Much that I freed returned to me."
(Lee Wilson Dodd)
1) Right now I put the report title simply on the first row, using:
Set xlsApp = new Excel.Application
With xlsApp
.Visible = true
.Workbooks.Add
.Cells(1,1).Value = "REPORT TITLE"
.Cells(1,1).Font.Bold = True
(after which I add the column headers and the actual records with more .Cells(X,X).Value statements in a loop.)
(...)
(...)
End With
The user would like to be able to sort the columns after output, though, and the report title is getting in the way of this. She's asked me to have the application put it in the sheet's header instead of on the first row. Is this possible from VB and if so which command would I use?
2) In one of the columns I output, I'd like to align the text to the right. I'm looking for a command along the lines of "xlsapp.Cells(X,X).Align = Right" or such which I could then use in a loop; or alternatively a command that affects the entire column at once. Is there such a command and what's the proper syntax for it?
Thanks in advance!
"Much that I bound, I could not free. Much that I freed returned to me."
(Lee Wilson Dodd)