msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Using VB6 and OLE to add a new column to an existing Excel w

 
Post new topic   Reply to topic    msvisual.com Forum Index -> OLE Automation
Author Message
canoe414



Joined: 04 Oct 2007
Posts: 28

PostPosted: Tue Oct 17, 2006 1:47 pm    Post subject: Using VB6 and OLE to add a new column to an existing Excel w Reply with quote

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

Archived from group: microsoft>public>vb>ole>automation
Back to top
View user's profile Send private message
Bob Phillips



Joined: 04 Oct 2007
Posts: 10

PostPosted: Tue Oct 17, 2006 10:04 pm    Post subject: Re: Using VB6 and OLE to add a new column to an existing Exc Reply with quote

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@k70g2000cwa.googlegroups.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
>
Back to top
View user's profile Send private message
canoe414



Joined: 04 Oct 2007
Posts: 28

PostPosted: Tue Oct 17, 2006 5:03 pm    Post subject: Re: Using VB6 and OLE to add a new column to an existing Exc Reply with quote

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
Back to top
View user's profile Send private message
Bob Phillips



Joined: 04 Oct 2007
Posts: 10

PostPosted: Wed Oct 18, 2006 3:58 am    Post subject: Re: Using VB6 and OLE to add a new column to an existing Exc Reply with quote

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)

wrote in message@f16g2000cwb.googlegroups.com...
> 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
>
Back to top
View user's profile Send private message
Dmitriy Antonov



Joined: 04 Oct 2007
Posts: 431

PostPosted: Wed Oct 25, 2006 1:48 am    Post subject: Re: Using VB6 and OLE to add a new column to an existing Exc Reply with quote

wrote in message @k70g2000cwa.googlegroups.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
>

Check here, maybe this is what you are asking for:
http://support.microsoft.com/kb/285332

Check References within that article for more links.

Dmitriy.
Back to top
View user's profile Send private message
Dmitriy Antonov



Joined: 04 Oct 2007
Posts: 431

PostPosted: Wed Oct 25, 2006 3:38 am    Post subject: Re: Using VB6 and OLE to add a new column to an existing Exc Reply with quote

"Dmitriy Antonov" wrote in message @TK2MSFTNGP03.phx.gbl...
>
> wrote in message
> @k70g2000cwa.googlegroups.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
>>
>
> Check here, maybe this is what you are asking for:
> http://support.microsoft.com/kb/285332
>
> Check References within that article for more links.
>
> Dmitriy.
>

Oops. I accidentally misplaced my reply. It applies to another post (the
one, which is just above it) - so please disregard it here.

Dmitriy.

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    msvisual.com Forum Index -> OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group