Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / June 2007

Tip: Looking for answers? Try searching our database.

Excel automation problems from VB/VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
numerista@gmail.com - 19 Jun 2007 18:16 GMT
Hi,

I am using Visual Basic 6 to automate Excel.

When the reference to Excel is early bound (bound to Excel at design
time), everything works fine, for example
e.Range(e.Cells(w, x), e.Cells(y,z)).HorizontalAlignment = xlCenter
centers the text in a merged cell.

When changing that to early binding, I get errors telling me that the
HorizontalAlignment is not part of the e.range class, though other
operations work OK.

Anyone have any ideas?

Cheers,
Daniel
Dave Peterson - 19 Jun 2007 18:35 GMT
When changing to late binding????

Maybe it's not .horizontalalignment that's the problem.

Maybe it's xlcenter.

I'd try
e.Range(e.Cells(w, x), e.Cells(y,z)).HorizontalAlignment = -4108

From Excel's VBE's immediate window:
?xlCenter
-4108

> Hi,
>
[quoted text clipped - 13 lines]
> Cheers,
> Daniel

Signature

Dave Peterson

numerista@gmail.com - 20 Jun 2007 09:36 GMT
Thanks Dave. You've a star!

It seems like when doing early binding, the constants are not set up
in the same way as with late binding...

Ok, so now back to the VBA help for the full codes for the other
constants which also have the same problem (but included in a "on
error goto next" section and so failing silently).

Thanks for the immediate window tip, or I'd be plowing through the VBA
helpfiles!

Cheers,
Daniel

> When changing to late binding????
>
[quoted text clipped - 34 lines]
>
> - Afficher le texte des messages pr?c?dents -
Dave Peterson - 20 Jun 2007 12:58 GMT
Yep.  If you're using a reference, then excel knows what those constants are.

If you don't, then they'll be treated as unitialized.  If you add "option
Explicit" to the top of your module, excel won't even let you compile your code
successfully--it won't know what xlCenter is.

You can also search the Object Browser in the VBE (hit F2 to see it) and then
search for your constant.

> Thanks Dave. You've a star!
>
[quoted text clipped - 49 lines]
> >
> > - Afficher le texte des messages précédents -

Signature

Dave Peterson


Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.