Export to Snapshot

H

hlam

I have VBA to export report to snapshot on a designated drive. However the
file is not exported if it is being viewed and there is no message reported
to the user. Is there a way I can test if the snapshot is being viewed
before export?
 
G

Graham Mandeno

When you say the file is being viewed, do you mean that a previous version
of the SNP file already exists and is being viewed?

If so, try to delete the file first:
Kill "C:\some path\some file.snp"

If the file is open, then it cannot be deleted, and an error will be raised.
 
H

hlam

I tried to use both Kill and Deletefile method but non of them return me
with an error. Here are the codes:

rptdrive = "D:/VCS/Productivity Reports/test.snp"
'test if folder is exist, if not exit process
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FolderExists(rptdrive) = False Then
MsgBox "Folder does not exist, file is not exported "
Exit Function
End If
'delete existing file
dfile = rptdrive
' tried both codes below but still no error reported
Kill dfile
fs.deletefile (dfile), True


Graham Mandeno said:
When you say the file is being viewed, do you mean that a previous version
of the SNP file already exists and is being viewed?

If so, try to delete the file first:
Kill "C:\some path\some file.snp"

If the file is open, then it cannot be deleted, and an error will be raised.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

I have VBA to export report to snapshot on a designated drive. However the
file is not exported if it is being viewed and there is no message
reported
to the user. Is there a way I can test if the snapshot is being viewed
before export?
 
G

Graham Mandeno

Do you mean you execute the Kill line, and the file still exists but an
error is NOT raised???

Are you absolutely sure you have not disabled error handling (On Error
Resume Next)?

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

hlam said:
I tried to use both Kill and Deletefile method but non of them return me
with an error. Here are the codes:

rptdrive = "D:/VCS/Productivity Reports/test.snp"
'test if folder is exist, if not exit process
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FolderExists(rptdrive) = False Then
MsgBox "Folder does not exist, file is not exported "
Exit Function
End If
'delete existing file
dfile = rptdrive
' tried both codes below but still no error reported
Kill dfile
fs.deletefile (dfile), True


Graham Mandeno said:
When you say the file is being viewed, do you mean that a previous
version
of the SNP file already exists and is being viewed?

If so, try to delete the file first:
Kill "C:\some path\some file.snp"

If the file is open, then it cannot be deleted, and an error will be raised.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

I have VBA to export report to snapshot on a designated drive. However the
file is not exported if it is being viewed and there is no message
reported
to the user. Is there a way I can test if the snapshot is being viewed
before export?
 
Top