Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to close a TIFF file using VBA

Posted on 2010-11-15
4
Medium Priority
?
243 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 2000 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

927 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