+ Reply to Thread
Results 1 to 16 of 16

Shapes works in one workbook but not another

  1. #1
    Registered User
    Join Date
    11-26-2009
    Location
    Aarhus, Denmark
    MS-Off Ver
    Excel 2019
    Posts
    46

    Shapes works in one workbook but not another

    I've designed a procedure that, via shapes, draws a beam and the forces acting on the beam.
    Depending on the size of the beam, the size and placement of the forces etc. the procedure places and sizes the beam and forzes correspondingly.

    I've originally made this procedure on a blank workbook just to get the drawingprocedure in place and it works fine.

    But when i copy the procedure into the workbook containing the beamcalculations errors occur and only some of the shapes are drawn (i've mad sure that all the input referencecells are updated).

    Here is some of the original code that works fine as a stand-alone with corresponding inputdata from the following cells. When i copy the code into the other workbook i get the first error in this part of the code:

    Please Login or Register  to view this content.
    I get the first errror in the line.style-statement:

    "Run time error '-2147024809 (80070057)': the stated value is outside the limits"

    or

    "Run time error "438": Object doesn't support this property or method"



    Here is a larger part of the code.

    I get a lot of similar errors working down the code

    Please Login or Register  to view this content.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Shapes works in one workbook but not another

    Linestyle should be one of the following values.

    msoLineSingle 1
    msoLineThickBetweenThin 5
    msoLineThinThick 3
    msoLineStyleMixed -2
    msoLineThickThin 4
    msoLineThickThin 2

    your code results in either 0 or -1, both of which are invalid and will raise the outside the limits error.
    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    11-26-2009
    Location
    Aarhus, Denmark
    MS-Off Ver
    Excel 2019
    Posts
    46

    Re: Shapes works in one workbook but not another

    Hello Andy.

    That's not the problem.

    The code looks like this: (i accidently copied two line together in the first post)

    Please Login or Register  to view this content.
    The stand-alone code i wrote works with a part of the code looking like the above

  4. #4
    Registered User
    Join Date
    11-26-2009
    Location
    Aarhus, Denmark
    MS-Off Ver
    Excel 2019
    Posts
    46

    Re: Shapes works in one workbook but not another

    Now i've tryed to have both my main workbook and the drawing workbook open.

    If i call the drawingprocedure (located in the drawing workbook) from my main workbook it works just fine.

    But if i copy the drawing procedure from the drawing workbook to my main workbook and then calls the same procedure (now loacated in main workbook) if fails!

    I'm very confused

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Shapes works in one workbook but not another

    As you point out your code works.

    Can you post an example workbook that produces the error?

  6. #6
    Registered User
    Join Date
    11-26-2009
    Location
    Aarhus, Denmark
    MS-Off Ver
    Excel 2019
    Posts
    46

    Re: Shapes works in one workbook but not another

    Quote Originally Posted by Andy Pope View Post
    As you point out your code works.

    Can you post an example workbook that produces the error?
    I'll post the complete drawingprocedure first (in the next couple of post due to max lenght in one post):

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    11-26-2009
    Location
    Aarhus, Denmark
    MS-Off Ver
    Excel 2019
    Posts
    46

    Re: Shapes works in one workbook but not another

    Please Login or Register  to view this content.

  8. #8
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Shapes works in one workbook but not another

    You need to tell us the values on the sheet that the program uses.
    Also how are you running the routines, from a shortcut or button or macro dialog?

  9. #9
    Registered User
    Join Date
    11-26-2009
    Location
    Aarhus, Denmark
    MS-Off Ver
    Excel 2019
    Posts
    46

    Re: Shapes works in one workbook but not another

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    11-26-2009
    Location
    Aarhus, Denmark
    MS-Off Ver
    Excel 2019
    Posts
    46

    Re: Shapes works in one workbook but not another

    The in-data could be:

    O46: the length of the beam (in meters, ex: 4.0)
    O19: The uniform load (in kN/m, ex. 5.0)
    O25: Pointload #1 (in kN, ex: 3.0)
    O32: Pointload #2 (in kN, ex. 6.0)
    O26: the placement of pointload #1 (in meters, ex. 1.5)
    O33: the placement of pointload #2 (in meters, ex. 3.4)
    O35: relative moment at left side (in percentage, ex. 50)
    O36: relative moment at right side (in percentage, ex 50)

    I start the procedure with the click of a button

  11. #11
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Shapes works in one workbook but not another

    What type of button? Form or ActiveX
    Button on the same sheet?

    I do not get an error when I build a workbook with your code.

  12. #12
    Registered User
    Join Date
    11-26-2009
    Location
    Aarhus, Denmark
    MS-Off Ver
    Excel 2019
    Posts
    46

    Re: Shapes works in one workbook but not another

    Quote Originally Posted by Andy Pope View Post
    What type of button? Form or ActiveX
    Button on the same sheet?

    I do not get an error when I build a workbook with your code.
    A form-button.

    No the code i just posted works fine for me to as a standalone or if i call it from my beamcalculationprogram (my mainprocedure in the mainworkbook).

    But if i copy the procedure into my mainworkbook i get multiple run-time errors.

  13. #13
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Shapes works in one workbook but not another

    I'm not sure how to help then. Without your main workbook I can not repoduce your problem.

  14. #14
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Shapes works in one workbook but not another

    Kim1974 provided me the full workbooks offline so I could debug the problem.

    It turns out the workbook did not have a reference to the Microsoft Office Object library. This caused a problem as the constant msoTrue was being used.

    Because of there being no reference the variable was empty.

    Add a reference via VBE. Tools > References.

  15. #15
    Registered User
    Join Date
    11-26-2009
    Location
    Aarhus, Denmark
    MS-Off Ver
    Excel 2019
    Posts
    46

    Re: Shapes works in one workbook but not another

    Thanks Andy!

  16. #16
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Shapes works in one workbook but not another

    This caused a problem as the constant msoTrue was being used.
    Kim should use Option Explicit.
    Entia non sunt multiplicanda sine necessitate

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1