Trying to Modify an existing Excel Spreadsheet, but can’t seem to get the syntax correct. I’ve come up with the following code. It compiles and runs, but doesn’t seem to do anything. Any help will be most appreciated.
[indent]
Private Sub FormatWorksheet()
Dim ws As Object
Dim xlApp As Object
Dim strFileName as string
strFileName = “serverdatafilename.xls”
Set xlApp = CreateObject(“Excel.Application”)
Set ws = xlApp.Workbooks.Open(strFileName)
xlApp.Visible = True ‘I know it works to this point since the correct file becomes visible here
However, nothing below here seems to do anything.
ws.Cells.Select
With Selection.Font
.Name = “Arial”
.Size = 10
End With
With ws
.Rows(“1:3”).Select
.Selection.Insert Shift:=xlDown
.Range(“E6”).Select
.Selection.Cut Destination:=Range(“B1”)
. Range(“B1”).Select
.Selection.NumberFormat = “m/d/yyyy hh:mm;@”
.Range(“A1”).Select
.ActiveCell.FormulaR1C1 = “Report Run:”
.Columns(“E:E”).Select
.Selection.Delete Shift:=xlToLeft
.Cells.EntireColumn.AutoFit
.Columns(“D:D”).Select
.Selection.NumberFormat = “#,##0.00”
.Close (True)
Set ws = Nothing
Exit_Sub:
Exit Sub
[/indent]
Any suggestions would be greatly appreciated.