Runtime error 1004

  • Thread starter Thread starter edreczk
  • Start date Start date
E

edreczk

I open an Excel spreadsheet from within MS Access 2003.

I have the following code:

ExcelSheet.Application.Rows(intRow & ":" & intRow).Select
ExcelSheet.Application.Selection.Font.Bold = True
ExcelSheet.Application.Columns("B:B").Select
ExcelSheet.Application.Selection.HorizontalAlignment
"xlRight"


The first three lines work fine.
I select the current row and set the font to bold.
I then select colum B and want to set it to right align.

I get the following error msg:

Run-time error '1004'
Unable to set the HorizontalAlignment property of the Range class.

Found a tip on MS.com where you set Macro Security to allow VBA...
this doesn't work in this situation.

I created a macro within Excel, which works fine... just not fro
within MS Access.

Any ideas
 
ExcelSheet.Application.Rows(intRow & ":" & intRow).Select
ExcelSheet.Application.Selection.Font.Bold = True
ExcelSheet.Application.Columns("B:B").Select
ExcelSheet.Application.Selection.HorizontalAlignment = xlRight

Take the quotes off xlRight

if you are using late binding, use the value of the constant:

ExcelSheet.Application.Selection.HorizontalAlignment = -4152
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top