+ Reply to Thread
Results 1 to 3 of 3

Object problems

  1. #1
    Registered User
    Join Date
    12-03-2012
    Location
    Soth Africa
    MS-Off Ver
    Excel 2007
    Posts
    3

    Exclamation Object problems

    Greetings

    I currently have a sheet where u click a button, it makes a copy of the sheet and then deletes certain object.
    For arguments sake, lets say the one rectangle is "Object 5" and then it gets deleted.

    Here is where the problem lies:

    It works fine on my computer but as soon as i copy it over to another computer and run it from there, i get a debug error stating "cannot find object" and then it references to the object in the macro code, and the object renamed itself e.g. "object 22" and then it cant delete it.

    I have absolutely no clue why the moment when it is copied to another computer why this happens...

    Any help will be appreciated.

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: Object problems

    If you draw the object from code it can take another progressive name, you could use the .name attribute to change the object name when you draw it, for example:
    Please Login or Register  to view this content.
    so you can easily delete it using the name:
    Please Login or Register  to view this content.
    Regards,
    Antonio

  3. #3
    Registered User
    Join Date
    12-03-2012
    Location
    Soth Africa
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Object problems

    This does certaintly work, "ActiveSheet.Shapes("object 5").Delete" but as stated as soon as the sheet is copied over to another computer, then the object itself changes. It is still object 2, but as soon as i run the macro and the new form is created and the shape needs to be deleted, the object changes itself. Trust me i know this sounds confusing but if it was straight forward i wouldnt be pulling my hair out. I double checked the macro and the macro is fine. Here is an example of what happens

    Sheets("test").Select
    Sheets("test").Copy Before:=Sheets(4)
    Sheets("test (2)").Select
    Sheets("test (2)").Name = "jobtest"
    ActiveSheet.Shapes("Object 2").Delete

    IT works 100% fine on my laptop, and it deletes the shape, bob's your uncle. but when it is copied over, the object is object 2 still, but when the macro is run, on the new form when the debugger comes up, on the first sheet it is object 2, but on the new sheet it is object 5 and doesnt delete since there is no object 5. sorry if this sounds weird but it is irritating me cuz i do not know what is the cause of the problem

+ 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