Solved

How to close a TIFF file using VBA

Posted on 2010-11-15
4
196 Views
Last Modified: 2014-06-16
I have a program where I display a list of TIFF files on a form.  The user clicks one, it opens, they select several things on the form that creates a new name\location for the file.  I copy the file to a new location with the new name.  

Now I just need to close and kill the file that was just copied.  Everything is working perfectly and this seems so simple.  I know the full file name and just want to close and kill it.  Ironically, when I run the same application in Citrix, KILL and the filename works.  It doesn't matter that it's open.  Any assistance would be greatly appreciated!
0
Comment
Question by:Sash98
4 Comments
 
LVL 17

Accepted Solution

by:
JezWalters earned 500 total points
Comment Utility
It's a bit of overkill (no pun intended!), but have you tried the following?
Reset

Kill <full path to your TIFF file>

Open in new window

0
 
LVL 13

Expert Comment

by:gbanik
Comment Utility
U r using VBA.

Alomost always file operations do not release the file instantly. One bad... but effective way is to wait for sometime and then try killing it.

Following is a code that tries for 10 seconds.
Option Explicit

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)



Public Sub YourSubroutine()

'.....your code here



Dim iCtr As Integer

On Error Resume Next

Do While iCtr < 10

    DoEvents

    DoEvents

    DoEvents

    Kill sYourFileName

    Sleep 1000

    iCtr = iCtr + 1

    If Dir(sYourFileName) = "" Then Exit Do

Loop

If Err.Number <> 0 Then Err.Clear



End Sub

Open in new window

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now