PC Review


Reply
Thread Tools Rate Thread

Access-to-Excel Automation

 
 
=?Utf-8?B?Qm9iIEJhcm5lcw==?=
Guest
Posts: n/a
 
      16th May 2006
How can I set HorizontalAlignment = xlRight
of a Column or Range thru automation in Access VBA?

Example...this works..
objXLSheet.Columns("F:F").ColumnWidth = 14

This doesn't...
objXLSheet.Range("F1:F500").HorizontalAlignment = xlRight

I am Formatting "Fixed" in an Access Query, but it always left-aligns
in Excel.

Any tips?

TIA - Bob
 
Reply With Quote
 
 
 
 
Douglas J Steele
Guest
Posts: n/a
 
      16th May 2006
Do you have a reference set to Excel, or are you using Late Binding?

See whether it makes a difference if you use the actual value of
xlRight, -4152:

objXLSheet.Range("F1:F500").HorizontalAlignment = -4152


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Bob Barnes" <(E-Mail Removed)> wrote in message
news:A3B5901A-3175-4828-9C67-(E-Mail Removed)...
> How can I set HorizontalAlignment = xlRight
> of a Column or Range thru automation in Access VBA?
>
> Example...this works..
> objXLSheet.Columns("F:F").ColumnWidth = 14
>
> This doesn't...
> objXLSheet.Range("F1:F500").HorizontalAlignment = xlRight
>
> I am Formatting "Fixed" in an Access Query, but it always left-aligns
> in Excel.
>
> Any tips?
>
> TIA - Bob



 
Reply With Quote
 
=?Utf-8?B?TWljaGFlbCBI?=
Guest
Posts: n/a
 
      16th May 2006
Bob,

Access doesn't know about the Excel constant xlRight. If you open the VB
Editor in Excel, and type ? xlRight into the Debug window, you will see
that the constant equals -4152. So, try this:

objXLSheet.Range("F1:F500").HorizontalAlignment = -4152

-Michael


"Bob Barnes" wrote:

> How can I set HorizontalAlignment = xlRight
> of a Column or Range thru automation in Access VBA?
>
> Example...this works..
> objXLSheet.Columns("F:F").ColumnWidth = 14
>
> This doesn't...
> objXLSheet.Range("F1:F500").HorizontalAlignment = xlRight
>
> I am Formatting "Fixed" in an Access Query, but it always left-aligns
> in Excel.
>
> Any tips?
>
> TIA - Bob

 
Reply With Quote
 
Douglas J Steele
Guest
Posts: n/a
 
      16th May 2006
Actually, Access will know what the Excel constant xlRight is if you've got
a reference set to Excel.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Michael H" <(E-Mail Removed)> wrote in message
news:0987EFD9-21AE-4AC4-AFA9-(E-Mail Removed)...
> Bob,
>
> Access doesn't know about the Excel constant xlRight. If you open the VB
> Editor in Excel, and type ? xlRight into the Debug window, you will

see
> that the constant equals -4152. So, try this:
>
> objXLSheet.Range("F1:F500").HorizontalAlignment = -4152
>
> -Michael
>
>
> "Bob Barnes" wrote:
>
> > How can I set HorizontalAlignment = xlRight
> > of a Column or Range thru automation in Access VBA?
> >
> > Example...this works..
> > objXLSheet.Columns("F:F").ColumnWidth = 14
> >
> > This doesn't...
> > objXLSheet.Range("F1:F500").HorizontalAlignment = xlRight
> >
> > I am Formatting "Fixed" in an Access Query, but it always left-aligns
> > in Excel.
> >
> > Any tips?
> >
> > TIA - Bob



 
Reply With Quote
 
=?Utf-8?B?TWljaGFlbCBI?=
Guest
Posts: n/a
 
      16th May 2006
Hi Douglas.

Since it wasn't working for Bob, I assumed he didn't have the reference set.
I probably should have asked instead of assuming.

-Michael

"Douglas J Steele" wrote:

> Actually, Access will know what the Excel constant xlRight is if you've got
> a reference set to Excel.
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "Michael H" <(E-Mail Removed)> wrote in message
> news:0987EFD9-21AE-4AC4-AFA9-(E-Mail Removed)...
> > Bob,
> >
> > Access doesn't know about the Excel constant xlRight. If you open the VB
> > Editor in Excel, and type ? xlRight into the Debug window, you will

> see
> > that the constant equals -4152. So, try this:
> >
> > objXLSheet.Range("F1:F500").HorizontalAlignment = -4152
> >
> > -Michael
> >
> >
> > "Bob Barnes" wrote:
> >
> > > How can I set HorizontalAlignment = xlRight
> > > of a Column or Range thru automation in Access VBA?
> > >
> > > Example...this works..
> > > objXLSheet.Columns("F:F").ColumnWidth = 14
> > >
> > > This doesn't...
> > > objXLSheet.Range("F1:F500").HorizontalAlignment = xlRight
> > >
> > > I am Formatting "Fixed" in an Access Query, but it always left-aligns
> > > in Excel.
> > >
> > > Any tips?
> > >
> > > TIA - Bob

>
>
>

 
Reply With Quote
 
=?Utf-8?B?Qm9iIEJhcm5lcw==?=
Guest
Posts: n/a
 
      16th May 2006
Doug - THANK you.

I had Office 11.0 Object Library & NOT Excel 11.0 Object Library referenced.

"-4152" Works without Excel 11.0 Object Library referenced...but now I have
it checked. Therefore xlRight works now.

Bob

"Douglas J Steele" wrote:

> Do you have a reference set to Excel, or are you using Late Binding?
>
> See whether it makes a difference if you use the actual value of
> xlRight, -4152:
>
> objXLSheet.Range("F1:F500").HorizontalAlignment = -4152
>
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "Bob Barnes" <(E-Mail Removed)> wrote in message
> news:A3B5901A-3175-4828-9C67-(E-Mail Removed)...
> > How can I set HorizontalAlignment = xlRight
> > of a Column or Range thru automation in Access VBA?
> >
> > Example...this works..
> > objXLSheet.Columns("F:F").ColumnWidth = 14
> >
> > This doesn't...
> > objXLSheet.Range("F1:F500").HorizontalAlignment = xlRight
> >
> > I am Formatting "Fixed" in an Access Query, but it always left-aligns
> > in Excel.
> >
> > Any tips?
> >
> > TIA - Bob

>
>
>

 
Reply With Quote
 
=?Utf-8?B?Qm9iIEJhcm5lcw==?=
Guest
Posts: n/a
 
      16th May 2006
THANKS Michael...I answered Doug (above) w/ this...

Doug - THANK you.

I had Office 11.0 Object Library & NOT Excel 11.0 Object Library referenced.

"-4152" Works without Excel 11.0 Object Library referenced...but now I have
it checked. Therefore xlRight works now.

Bob

"Michael H" wrote:

> Hi Douglas.
>
> Since it wasn't working for Bob, I assumed he didn't have the reference set.
> I probably should have asked instead of assuming.
>
> -Michael
>
> "Douglas J Steele" wrote:
>
> > Actually, Access will know what the Excel constant xlRight is if you've got
> > a reference set to Excel.
> >
> > --
> > Doug Steele, Microsoft Access MVP
> > http://I.Am/DougSteele
> > (no e-mails, please!)
> >
> >
> > "Michael H" <(E-Mail Removed)> wrote in message
> > news:0987EFD9-21AE-4AC4-AFA9-(E-Mail Removed)...
> > > Bob,
> > >
> > > Access doesn't know about the Excel constant xlRight. If you open the VB
> > > Editor in Excel, and type ? xlRight into the Debug window, you will

> > see
> > > that the constant equals -4152. So, try this:
> > >
> > > objXLSheet.Range("F1:F500").HorizontalAlignment = -4152
> > >
> > > -Michael
> > >
> > >
> > > "Bob Barnes" wrote:
> > >
> > > > How can I set HorizontalAlignment = xlRight
> > > > of a Column or Range thru automation in Access VBA?
> > > >
> > > > Example...this works..
> > > > objXLSheet.Columns("F:F").ColumnWidth = 14
> > > >
> > > > This doesn't...
> > > > objXLSheet.Range("F1:F500").HorizontalAlignment = xlRight
> > > >
> > > > I am Formatting "Fixed" in an Access Query, but it always left-aligns
> > > > in Excel.
> > > >
> > > > Any tips?
> > > >
> > > > TIA - Bob

> >
> >
> >

 
Reply With Quote
 
aaron.kempf@gmail.com
Guest
Posts: n/a
 
      17th May 2006
i would reccomend not using Excel for anything; it isn't a valid
reporting format.

upgrade your piece of **** mdb app to sql server and use ADP or ADP to
get to the data.

MDB is a dead end road.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access automation leaves Excel open which in turn locks 2nd automation attempts EagleOne@discussions.microsoft.com Microsoft Access 8 30th Jun 2008 01:27 AM
Automation to Excel leaves Excel open until Access closed EagleOne@microsoftdiscussiongroups Microsoft Access 4 24th Jun 2008 11:00 PM
automation on excel(automated from Access VBA code) stops when opening another excel file thread Microsoft Access 1 27th Apr 2007 09:07 PM
Access-to-Excel Automation - Saving Excel w/ Custn Filename =?Utf-8?B?Qm9iIEJhcm5lcw==?= Microsoft Access VBA Modules 1 2nd Mar 2007 04:25 AM
Excel Automation - Access wants to re-open excel sheet when finish =?Utf-8?B?cGFzdG90bmlrcg==?= Microsoft Access VBA Modules 0 12th Apr 2006 07:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:59 PM.