newbie46
asked on
Overwriting file when saving Attachment to a Folder
I am using the following code to save an attachment to a folder:
set fDialog = Application.FileDialog(mso FileDialog FolderPick er)
if fDialog.Show = True then
strPath = fDialog.SelectedItems (1)
end if
select AttachedDocument
from tblA
set rst - db.OpenRecordset (strSQL, dbOpenDynaset)
if Not (rst.bof and rst.eof) then
do while not rst.eof
set rst2 = rst.fields("AttachedDocume nt").Value
rst2.openRecordset
rst2.Fields ("FileData").SaveToFile (strPath)
If the same named file already exists in the selected folder, an error is returned. Is it possible to overwrite the file existing within the selected folder with the attachment being saved?
set fDialog = Application.FileDialog(mso
if fDialog.Show = True then
strPath = fDialog.SelectedItems (1)
end if
select AttachedDocument
from tblA
set rst - db.OpenRecordset (strSQL, dbOpenDynaset)
if Not (rst.bof and rst.eof) then
do while not rst.eof
set rst2 = rst.fields("AttachedDocume
rst2.openRecordset
rst2.Fields ("FileData").SaveToFile (strPath)
If the same named file already exists in the selected folder, an error is returned. Is it possible to overwrite the file existing within the selected folder with the attachment being saved?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER