Board index » Excel » Using VB6 and OLE to add a new column to an existing Excel worksheet
|
Hennywati
|
|
Hennywati
|
Using VB6 and OLE to add a new column to an existing Excel worksheet
Excel173
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 - |
| Bob
Registered User |
Tue Oct 17 12:04:10 CDT 2006
Re: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) <canoe414@telecom-digest.zzn.com>wrote in message QuoteGreetings, - |
| canoe414
Registered User |
Tue Oct 17 15:03:29 CDT 2006
Re:Using VB6 and OLE to add a new column to an existing Excel worksheet
Thanks that seems to have worked. I mean, my app now runs to completion
without errors and does create a new .xls - but I can't open it with Excel to view it!! Any idea what could cause this behavior? Thanks for your previous help! Steve - |
| Bob
Registered User |
Tue Oct 17 17:58:03 CDT 2006
Re:Using VB6 and OLE to add a new column to an existing Excel worksheet
can you clarify what you mean, detail the steps that you took.
-- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) <canoe414@telecom-digest.zzn.com>wrote in message QuoteThanks that seems to have worked. I mean, my app now runs to completion - |
| Dmitriy
Registered User |
Tue Oct 24 20:48:37 CDT 2006
Re:Using VB6 and OLE to add a new column to an existing Excel worksheet<canoe414@telecom-digest.zzn.com>wrote in message QuoteGreetings, http://support.microsoft.com/kb/285332 Check References within that article for more links. Dmitriy. - |
| Dmitriy
Registered User |
Tue Oct 24 22:38:43 CDT 2006
Re:Using VB6 and OLE to add a new column to an existing Excel worksheet"Dmitriy Antonov" <antonovdima@netzero.net_NOT_FOR_SPAM>wrote in message Quote
one, which is just above it) - so please disregard it here. Dmitriy. - |
