![]() |
Error no. 1004
HI,
I am using the sample code below to draw borders in excel sheet from MSAccess Form. '--------------------------------------------------------------------------- ---------------------------------- Dim objXL As Excel.Application Dim objWkb As workbook Dim objSht As Worksheet Set objXL = Nothing Set objWkb = Nothing Set objSht = Nothing 'creating new excel object Set objXL = New Excel.Application Set objWkb = objXL.Workbooks.Add Set objSht = objWkb.Worksheets(1) Range("B" & Val(lngrow + 5) & ":AE" & Val(lngrow + 32)).Select Selection.Borders(xlDiagonalDown).LineStyle = xlNone Selection.Borders(xlDiagonalUp).LineStyle = xlNone With Selection.Borders(xlEdgeLeft) ..LineStyle = xlContinuous ..Weight = xlThin ..ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeTop) ..LineStyle = xlContinuous ..Weight = xlThin ..ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeBottom) ..LineStyle = xlContinuous ..Weight = xlThin ..ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeRight) ..LineStyle = xlContinuous ..Weight = xlThin ..ColorIndex = xlAutomatic End With Selection.Borders(xlInsideVertical).LineStyle = xlNone Selection.Borders(xlInsideHorizontal).LineStyle = xlNone '--------------------------------------------------------------------------- --------------------------------- I get the borders first time, when i run next time i am not getting borders and error occurs. but if i close application and then run , then the borders appear. err number - 1004, range object failed something like that Please help me. TIA, Cyrus |
Error no. 1004
Why don't you add a objXL.Visible = True so you can see what is happening?
When you say you run it a second time, you mean you're instantiating another instance of Excel? If so I don't know why the second instance should be affected by the first. If not, then you really didn't post the code you're running which makes it harder to help you. -- Jim Rech Excel MVP |
All times are GMT +1. The time now is 02:02 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com