Code doesn't release object.

User avatar
Don Wells
5StarLounger
Posts: 689
Joined: 27 Jan 2010, 16:45
Location: Ottawa, Ontario, Canada

Code doesn't release object.

Post by Don Wells »

    Running Office 2007

    The attached workbook contains a macro to determine the system Time Zone. In doing this it creates a folder (Get_Zone), on the Desktop. Throughout the process several files and another directory are created within Get_Zone and later deleted. Finally the code deletes the Get_Zone directory.

    My problem is that the folder Get_Zone remains on the desktop until the workbook is closed, at which time it is deleted without user intervention.

    Can someone please advise me on correcting this aggravation. I am loathe to adding code to close the workbook as a solution.

    Many thanks in advance.
You do not have the required permissions to view the files attached to this post.
Regards
Don

User avatar
HansV
Administrator
Posts: 78455
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Code doesn't release object.

Post by HansV »

The Flag subfolder disappears when I run the code, I don't have to wait until I close the workbook...
Best wishes,
Hans

User avatar
Don Wells
5StarLounger
Posts: 689
Joined: 27 Jan 2010, 16:45
Location: Ottawa, Ontario, Canada

Re: Code doesn't release object.

Post by Don Wells »

FWIW I'm running Windows 7; Office 2007, SP3
Regards
Don

User avatar
HansV
Administrator
Posts: 78455
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Code doesn't release object.

Post by HansV »

And FWIW, I'm running Windows 8.1 Update, Office 2013 SP1, but I don't think that would make a difference.
Best wishes,
Hans

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: Code doesn't release object.

Post by Rudi »

How about hiding the directory...
It still deletes only when the file closes, but you never see it :sneaky:
(Assuming the user is not showing hidden files)

Code: Select all

...
  un = Environ("username")
  dp = "C:\users\" & un & "\desktop\"
  
  MkDir (dp & dn)
  SetAttr dp & dn, vbHidden
  
  DoEvents
  Call Bat_File.create_run_delete_batch_file(bn, rn, dp & dn & "\")
...
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.