Microsoft Word - Macro Delete File

Add this macro.

' Makes sure all variables are dimensioned in each subroutine.
     Option Explicit
 
     ' Access the GetUserNameA function in advapi32.dll and
     ' call the function GetUserName.
     Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
 
Function Get_User_Name() As String
 
 
     ' Main routine to Dimension variables, retrieve user name
     ' and display answer.
 
 
     ' Dimension variables
     Dim lpBuff As String * 25
     Dim ret As Long, UserName As String
 
     ' Get the user name minus any trailing spaces found in the name.
     ret = GetUserName(lpBuff, 25)
     UserName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
 
     Get_User_Name = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
 
     ' Display the User Name
'     MsgBox UserName
 
End Function
 
 
 
 
 
Sub DeleteNavZUP()
'
' DeleteNavZUP Macro
'
 
    Dim fs, fil, fldr, strPathSet
 
    'Const System = 4
    'Const Hidden = 2
 
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    User_Name = Module1.Get_User_Name()
    'objFile.Attributes = System + Hidden
    Set objFile = objFSO.GetFile("C:\Documents and Settings\" & User_Name & "\Application Data\Nav6.zup")
    objFile.Delete
 
    'Set fs = CreateObject("Scripting.FileSystemObject")
    'strPath = InputBox("Enter Path of folder", "Find File")
 
    'If strPath = "" Or fs.FolderExists(strPath) = False Then
    '    MsgBox "Not a valid folder Path.", 64
    '    WScript.Quit
    'End If
 
    'Set fldr = fs.GetFolder(strPath)
 
    'For Each fil In fldr.Files
 
    '    If fil.Name = "Folder.jpg" Then
    '        'starts a dos box and runs a command
    '        Dim strCommand, objShell, objExec
    '        strCommand = "attrib -S -H " & Chr(34) & fil.Path & Chr(34)
    '        Set objShell = CreateObject("WScript.Shell")
    '        Set objExec = objShell.Exec(strCommand)
    '    End If
    'Next
 
End Sub