View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jon Peltier Jon Peltier is offline
external usenet poster
 
Posts: 6,582
Default Trying to convert from Early to Late binding

You have to convert constants like xlDiagonalDown into their numerical
equivalents. In Excel's Immediate Window, type a question mark and the
constant, and press enter to get the value:

?xlDiagonalDown
5

Also make sure that the variables are declared (Dim statements) as Object,
not as any of the Excel variable types. You are declaring the variables,
aren't you?

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"David" wrote in message
...
Hello all,
I am using this code in Access 2003, VBA. This bit of code that works
well
with a reference to Excel 2003, unfortunately I need to try and convert
this
to Late binding so I can remove the reference to Excel 2003. I'm not very
familar with early binding/late binding. So please forgive me if I am
mis-speaking.

I am getting error 1004 - Application defined or object defined error on
line 820.

Can someone help me re-work this code to Late Binding?

790 Set objActiveWkb = objXLBook.Application.ActiveWorkbook


'*********** MAIN WITH statement

800 With objActiveWkb 'Main With Statement

810 .Application.Range("A1:W1").Select


820 .Application.Selection.Borders(xlDiagonalDown).Lin eStyle =
xlNone

830 .Application.Selection.Borders(xlDiagonalUp).LineS tyle =
xlNone

840 With .Application.Selection.Borders(xlEdgeLeft)
850 .LineStyle = xlContinuous
860 .Weight = xlThin
870 .ColorIndex = xlAutomatic
880 End With

890 With .Application.Selection.Borders(xlEdgeTop)
900 .LineStyle = xlContinuous
910 .Weight = xlThin
920 .ColorIndex = xlAutomatic
930 End With

The code continues with a series of with blocks to format the
xlEdgeBottom,
xlEdgeRight, xlInsideVertical.

Then a final End If statement.


Thank you for your assistance.