View Single Post
  #2   Report Post  
Posted to microsoft.public.vb.ole.automation,microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Using VB6 and OLE to add a new column to an existing Excel worksheet

Sub addcolum()
Dim xlApp As Object
Dim xlWB As Object
Dim xlWS As Object

Set xlApp = CreateObject("Excel.Application")
Set xlWB = xlApp.Workbooks.Open("C:\myDir\myBook.xls") '<=== change to
suit
Set xlWS = xlWB.Worksheets(1)
xlWS.Columns(1).Insert

Set xlWS = Nothing
Set xlWB = Nothing
xlApp.Quit
Set xlApp = Nothing

End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

wrote in message
oups.com...
Greetings,

Is it possible to programmatically add a new column to an existing
Excel worksheet using VB 6.0 and OLE? Or VB 6.0 and ??? It's OK if the
added column becomes the new "A" column and shifts all previously
existing columns over one. I 'haven't been able to google up any
coding examples that do this. Examples are always welcome.

TIA,

Steve