Consulting

Results 1 to 10 of 10

Thread: Strange Occcurance

  1. #1
    VBAX Regular
    Joined
    May 2004
    Location
    UK
    Posts
    71
    Location

    Strange Occcurance

    I am running my macros, If i run them without the file being shared they are working ok, but if i then share my file i get this strange message, and i have looked at it and i can not see what it means.

    Here is the message i get:
    Quote Originally Posted by Error Message
    Can not rename a sheet to the same name as another sheet, Referenced object library or a workbook referenced by visual basic.
    Lets hope some one can shed some light on this one.

    This only happens when i am in shared mode, so i can not even run the macro line by line to see where it stops at, as you can not edit a macro when the file is shared.
    The macro transfer's data over a week, the sheets are named sunday through to saturday, if i transfer the data a day at a time it will only do the first day before it stops, yet when the file is not in share mode it goes all through the week.

    Thanks

    Ian

  2. #2
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    Add a reference to Microsoft Excel Object Library 9.0
    then declare objExcel like this:

    Dim objExcel as Excel.Application
    after you are done doing what you want and are ready
    to exit,
    Before you do:

    Set objExcel = Nothing
    Do this

    objExcel.Quit

    HTH
    Peace of mind is found in some of the strangest places.

  3. #3
    VBAX Regular
    Joined
    May 2004
    Location
    UK
    Posts
    71
    Location
    Thank you for the reply austenr, I will try that, but first how do i Add a reference to Microsoft Excel Object Library 9.0

    Thanks



    Ian
    One Day Soon I will Be able to Answer a question On Here, But until that day I have to rely on All the other coders to give me the answers.

  4. #4
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Hello Ian,

    From the VBE (Alt + F11) goto Tools --> References. Check the appropriate reference and click Ok.

    That's it!

  5. #5
    VBAX Regular
    Joined
    May 2004
    Location
    UK
    Posts
    71
    Location
    Thanks for the reply Zack, Just tried that, it was already referenced, so i put the code in that austenr posted but still not working.


    Regards

    Ian
    One Day Soon I will Be able to Answer a question On Here, But until that day I have to rely on All the other coders to give me the answers.

  6. #6
    VBAX Regular
    Joined
    May 2004
    Location
    UK
    Posts
    71
    Location
    I have found out what the problem is, but is there a way of getting around it.
    When the macros run it adds temp sheets to work with the data then it delete's them, that is where the problem starts, I have just realised that you can not delete a sheet in shared mode, so does anybody know of a way round this

    Thanks

    Ian
    One Day Soon I will Be able to Answer a question On Here, But until that day I have to rely on All the other coders to give me the answers.

  7. #7
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Can you create a new workbook instead, and then Kill it when done? This should work because you wouldn't be affecting the current workbook with adding/deleting any worksheets.

  8. #8
    VBAX Regular
    Joined
    May 2004
    Location
    UK
    Posts
    71
    Location
    Thanks for that Zack, I will give that a try, That is a good Idea, I never thought of doing it that way, But will it slow it down much by creating a new workbook, as i will need to creat a workbook with at least 5 sheets in it

    Also will it be better to creat a macro to make the workbook and then call it up when needed, and then another to delete the new workbook.

    Regards

    Ian
    One Day Soon I will Be able to Answer a question On Here, But until that day I have to rely on All the other coders to give me the answers.

  9. #9
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    If you're going to do that, I suggest you keep a location on your hard drive for this temporary file. E.g. "C:\temp.xls". And I'd only suggest this if the file would be used quite a bit by other routines. Otherwise, it may be just as fast to open a file, edit what you want, then close w/o saving changes.

  10. #10
    VBAX Regular
    Joined
    May 2004
    Location
    UK
    Posts
    71
    Location
    I know that it has took me a long time to reply to this but i have been busy at work, but i am going to mark this as solved, I realised that when you share a workbook you can not delete sheets in share mode, so i just inserted the sheets on a permanent basis and then hid them.

    Regards

    Ian
    One Day Soon I will Be able to Answer a question On Here, But until that day I have to rely on All the other coders to give me the answers.

Posting Permissions

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