ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Stepping Problem, (https://www.excelbanter.com/excel-programming/352693-stepping-problem.html)

ben

Stepping Problem,
 
I know I posted this earlier, but the response I recieved did not help any.
Though I did appreciate the response.

Stepping through a program will achieve the desired results, but running it
normally will error out.

First, a Worksheet Change Event is recieved, this in turns calls a Sub to
add an AutoShape to a worksheet.
If code is allowed to run normally I will always recieve a
1004 Application-Defined or Object Defined error at the line that actually
ADDS the shape

Set sh = wks.Shapes.AddShape(msoShapeDownArrow, 354.75, 162 + (rown * 21),
24, 30)

wks is passed as an argument to the sub from the worksheet change event and
sh is a shared public variable as Shape

when stepping the code does not error out.
Anyone know why this might be doing so?









--
When you lose your mind, you free your life.

Steve[_82_]

Stepping Problem,
 
Try this, I take it rown is the row number
this worked fine for me

Dim shp As Shape

Private Sub Workbook_SheetChange(ByVal sh As Object, ByVal Target As Range)

Set shp = sh.Shapes.AddShape(msoShapeDownArrow, 354.75, 162 +ActiveCell.Row
* 21, 24, 30)

End Sub



"ben" (remove this if mailing direct) wrote in message
...
I know I posted this earlier, but the response I recieved did not help any.
Though I did appreciate the response.

Stepping through a program will achieve the desired results, but running
it
normally will error out.

First, a Worksheet Change Event is recieved, this in turns calls a Sub to
add an AutoShape to a worksheet.
If code is allowed to run normally I will always recieve a
1004 Application-Defined or Object Defined error at the line that actually
ADDS the shape

Set sh = wks.Shapes.AddShape(msoShapeDownArrow, 354.75, 162 + (rown * 21),
24, 30)

wks is passed as an argument to the sub from the worksheet change event
and
sh is a shared public variable as Shape

when stepping the code does not error out.
Anyone know why this might be doing so?









--
When you lose your mind, you free your life.




[email protected]

Stepping Problem,
 
your code works well,
but shape is not visible.
so "shp.Visible = msoTrue" is required

Best regards
sjoo


ben

Stepping Problem,
 
This question was actually finally presented with a work around in a previous
post, it seems that other people have add this issue and had to have excel
Select something else (doesn't matter what) before creating the shape.

--
When you lose your mind, you free your life.


" wrote:

your code works well,
but shape is not visible.
so "shp.Visible = msoTrue" is required

Best regards
sjoo




All times are GMT +1. The time now is 04:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com