Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming,microsoft.public.word.vba.general
|
|||
|
|||
![]()
I'm running a macro in XL2007 in Vista which is manipulating a Word
document. At the end of everything, I want to delete the Word file. The Word file has been properly saved through VBA unsing SaveAs - it exists and I use the object to set ranges and such, so it's definitely a good file. But I can't delete it. I'm trying Kill and I'm trying FSO.DeleteFile. For some reason, my computer keeps flipping my file paths between C:\Users and C:\Documents and Settings, so I created two strings and am using both operations on both strings. Debug.Print shows good file paths. But the file won't go away!! Any help is greatly appreciated! Ed On Error Resume Next 'Delete Word doc strPath = objDoc.FullName strFile = Replace(strPath, "Users", "Documents and Settings") Debug.Print strPath Debug.Print strFile Stop Stop objDoc.Close SaveChanges:=wdSaveChanges x = 0 Do x = x + 1 objFSO.DeleteFile strPath, True objFSO.DeleteFile strFile, True Kill strPath Kill strFile If objFSO.FileExists(strPath) = False Then If objFSO.FileExists(strFile) = False Then Exit Do End If End If If x = 6 Then MsgBox "This program created a Word file." & _ vbCrLf & "Please delete this file." Exit Do End If Loop |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro to delete sheets and saves remaining file does not properly delete module | Excel Programming | |||
Macro to delete sheets and saves remaining file does not properly delete module | Excel Programming | |||
Macro to delete sheets and saves remaining file does not properly delete module | Excel Programming | |||
Macro to delete sheets and saves remaining file does not properly delete module | Excel Programming | |||
Macro to delete sheets and saves remaining file does not properly delete module | Excel Programming |