G
grace
Guest
I have generated some data using a cross-tab query and exported them into Excel. Now I need to open this excel file directly from current database and delete two columns from and then save it. I can see worksheet with C & D columns highlighted. But my code is not able to clear the contents. Please help!!!!!!!!
dim Myxl as object
Dim oWS As Object
'strAppPath is my excel file address
Set MyXL = GetObject(strAppPath)
MyXL.workbooks.Edit
MyXL.Application.Visible = True
MyXL.Parent.windows(1).Visible = True
beep
Set oWS = MyXL.activesheet
With oWS
.columns("C
").select
.Selection.ClearContents
End With
MyXL.ActiveWorkbook.Save
set ows = nothing
Set MyXL = Nothing
dim Myxl as object
Dim oWS As Object
'strAppPath is my excel file address
Set MyXL = GetObject(strAppPath)
MyXL.workbooks.Edit
MyXL.Application.Visible = True
MyXL.Parent.windows(1).Visible = True
beep
Set oWS = MyXL.activesheet
With oWS
.columns("C

.Selection.ClearContents
End With
MyXL.ActiveWorkbook.Save
set ows = nothing
Set MyXL = Nothing