Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default ms access 2k automation problem with selection

I copied some code from an Excel macro I created into an MS Access 2k
module. Much of it's fine except anything that

Set objActiveWkb = objXL.Application.ActiveWorkbook
With objActiveWkb
Range("A1:G1").Select
With Selection
.HorizontalAlignment = xlCenter <<<<<< ERROR HERE (and all next
lines in this "with")
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End With

I have my reference to Excel 11 set otherwise nothign would work. However,
the "Selection" object appears to have no properties or methods.

Do I need to do this instead (which does compile):

Set objActiveWkb = objXL.Application.ActiveWorkbook
With objActiveWkb
with Range("A1:G1") <<<<<<<< CHANGED LINE (and removed line "with
selection")
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End With


Thanks,

Keith



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default ms access 2k automation problem with selection

Unless you have created a reference to the excel object model, the constants
you are using are all equal to zero (i.e. undefined to access).

Replace them with the values they represent

? xlcenter
-4108
? xlbottom
-4107
? xlcontext
-5002

--
Regards,
Tom Ogilvy


"Keith G Hicks" wrote:

I copied some code from an Excel macro I created into an MS Access 2k
module. Much of it's fine except anything that

Set objActiveWkb = objXL.Application.ActiveWorkbook
With objActiveWkb
Range("A1:G1").Select
With Selection
.HorizontalAlignment = xlCenter <<<<<< ERROR HERE (and all next
lines in this "with")
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End With

I have my reference to Excel 11 set otherwise nothign would work. However,
the "Selection" object appears to have no properties or methods.

Do I need to do this instead (which does compile):

Set objActiveWkb = objXL.Application.ActiveWorkbook
With objActiveWkb
with Range("A1:G1") <<<<<<<< CHANGED LINE (and removed line "with
selection")
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End With


Thanks,

Keith




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default ms access 2k automation problem with selection

Thanks but xlCenter (and similar) is not the problem (as I said below the
2nd chunk of code compiles fine). The problem is
"Selection.HorizontalAlignment"

"HorizontalAlignment" is not showing up as a property of "Selection"

Keith

"Tom Ogilvy" wrote in message
...
Unless you have created a reference to the excel object model, the

constants
you are using are all equal to zero (i.e. undefined to access).

Replace them with the values they represent

? xlcenter
-4108
? xlbottom
-4107
? xlcontext
-5002

--
Regards,
Tom Ogilvy


"Keith G Hicks" wrote:

I copied some code from an Excel macro I created into an MS Access 2k
module. Much of it's fine except anything that

Set objActiveWkb = objXL.Application.ActiveWorkbook
With objActiveWkb
Range("A1:G1").Select
With Selection
.HorizontalAlignment = xlCenter <<<<<< ERROR HERE (and all

next
lines in this "with")
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End With

I have my reference to Excel 11 set otherwise nothign would work.

However,
the "Selection" object appears to have no properties or methods.

Do I need to do this instead (which does compile):

Set objActiveWkb = objXL.Application.ActiveWorkbook
With objActiveWkb
with Range("A1:G1") <<<<<<<< CHANGED LINE (and removed line

"with
selection")
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End With


Thanks,

Keith







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default ms access 2k automation problem with selection

then use

With objXL.Application.Selection

--
Regards,
Tom Ogilvy


"Keith G Hicks" wrote:

Thanks but xlCenter (and similar) is not the problem (as I said below the
2nd chunk of code compiles fine). The problem is
"Selection.HorizontalAlignment"

"HorizontalAlignment" is not showing up as a property of "Selection"

Keith

"Tom Ogilvy" wrote in message
...
Unless you have created a reference to the excel object model, the

constants
you are using are all equal to zero (i.e. undefined to access).

Replace them with the values they represent

? xlcenter
-4108
? xlbottom
-4107
? xlcontext
-5002

--
Regards,
Tom Ogilvy


"Keith G Hicks" wrote:

I copied some code from an Excel macro I created into an MS Access 2k
module. Much of it's fine except anything that

Set objActiveWkb = objXL.Application.ActiveWorkbook
With objActiveWkb
Range("A1:G1").Select
With Selection
.HorizontalAlignment = xlCenter <<<<<< ERROR HERE (and all

next
lines in this "with")
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End With

I have my reference to Excel 11 set otherwise nothign would work.

However,
the "Selection" object appears to have no properties or methods.

Do I need to do this instead (which does compile):

Set objActiveWkb = objXL.Application.ActiveWorkbook
With objActiveWkb
with Range("A1:G1") <<<<<<<< CHANGED LINE (and removed line

"with
selection")
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End With


Thanks,

Keith








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automation to Excel from Access Bob Barnes Excel Discussion (Misc queries) 1 February 11th 08 05:18 AM
.selection.find not working via automation Bill Schanks Excel Programming 1 June 27th 07 10:33 PM
Access to Excel Automation ADODB Problem Matt Slattery Excel Programming 2 September 29th 04 12:59 PM
OLE automation - use of .selection Richard Abrahams Excel Programming 1 September 11th 04 08:01 PM
Automation Code Problem from Access to Excel Tony Excel Programming 2 April 26th 04 12:58 AM


All times are GMT +1. The time now is 02:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"