+ Reply to Thread
Results 1 to 9 of 9

adding errorcode to vbcomponent not working

  1. #1
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    adding errorcode to vbcomponent not working

    here is the module code that is not working, i do have code that is working on a procedure that works ok.

    Please Login or Register  to view this content.
    what am i doing wrong
    Last edited by dmcgov; 05-24-2021 at 09:11 AM.

  2. #2
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: adding errorcode to vbcomponent not working

    making separate posts (as the code is too long for one post). here is the proc code that works perfectly.

    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: adding errorcode to vbcomponent not working

    and here is the sample MErrorTest3 module code to test the adderrcode procedure

    Please Login or Register  to view this content.
    and here is what it looks like when the code is ran:

    Please Login or Register  to view this content.
    what am i doing wrong, or how to fix this?
    Last edited by dmcgov; 05-24-2021 at 08:57 AM.

  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: adding errorcode to vbcomponent not working

    I think your code would be a lot simpler if you used things like Procofline

    Your code is flawed since you are trying to alter the end of a For loop from within that loop, which won't work. Have a look at this, and see how many times you think you'll see a message:

    Please Login or Register  to view this content.
    If you thought anything other than 1, you're mistaken.
    Rory

  5. #5
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: adding errorcode to vbcomponent not working

    rory,

    I would agree with you that i would only see the msgbox 1 time. but my FOR is dynamic so it reruns the loop when needed. see the following code. it is dynamic. let me know what you think. might need to loop using step -1 but you tell me if there is a better way (a sample of ProcOfLine would be great)

    Please Login or Register  to view this content.

  6. #6
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: adding errorcode to vbcomponent not working

    I feel slightly ill. That kind of thing is exactly why Goto is so frowned upon.

    See the 'Listing all procedures in a module' section here: http://www.cpearson.com/Excel/VBE.aspx

  7. #7
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: adding errorcode to vbcomponent not working

    so hopefully your over your illness :-) , so the next question is how would you do this? if goto's are frowned upon in loops, what is the best way to accomplish my goal of adding error code to all procs in a module? i did refer to chips site when i was making this sub.

  8. #8
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: adding errorcode to vbcomponent not working

    Personally I wouldn't, (if I really wanted to I'd use MZ Tools) but that doesn't really help you.

    As with all things in Excel when you are altering the loop, you should loop backwards. Then inserting rows after the point you're at will have no effect on your loop. Alternatively, you can build up a list of the procedures, then just iterate through that using ProcStartLine with the procedure name to find the start of the procedure and do your manipulation that way. Since you're finding the correct position each time, the inserting of lines will have no effect.

  9. #9
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: adding errorcode to vbcomponent not working

    thanks rorya, i had to beat it into my head that going forwards was never going to work. got it all sorted out.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Syntax error in writing code to reference a VBComponent
    By rn_ in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-25-2016, 02:34 PM
  2. [SOLVED] Adding line using VBComponent in ThisWorkbook
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-22-2014, 01:24 PM
  3. [SOLVED] Errorcode 91: Can't find my mistake
    By flo.111 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-01-2012, 08:37 AM
  4. Dim VBComp As VBIDE.VBComponent
    By Jim Jackson in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-14-2006, 04:15 PM
  5. VBIDE.VBComponent
    By michaelberrier in forum Excel General
    Replies: 3
    Last Post: 06-12-2006, 12:55 PM
  6. errorcode if somebody is trying to change ...
    By Martin Bauer in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-14-2006, 07:45 AM
  7. [SOLVED] Identifiying a Worksheets VBComponent
    By Rowan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-17-2005, 12:06 AM

Tags for this Thread

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