Solved

How to close a TIFF file using VBA

Posted on 2010-11-15
4
207 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
ID: 34144081
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
ID: 34144424
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

815 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

13 Experts available now in Live!

Get 1:1 Help Now