hi,
i want to pop up replace dialogue box for word file if file already exists at specified location.
thanks,
kk
Printable View
hi,
i want to pop up replace dialogue box for word file if file already exists at specified location.
thanks,
kk
are you using FSO? If so, use the fileexists method.
Can we see some code?
FSO?
i am new to VB6. have used so many years ago...
is there any save as method available for word file like excel file?
There are MANY ways to 'save as', yes....suggest you MSDN the FileSystemObject (FSO), or better yet, google it, and include the word "fileexists". Write some code so I'll know what you are attempting. There are other options, and FSO may not be the best....but I tend to use it a lot when working with files and directories.
Actually instead of the FSO you should use the built in DIR$() method.
Code:If Dir$(Filename)<>"" then
Roger, Data, You are right. But then if the file exists he'll have to decide to overwrite or cancel.
Krunel....if you want a saveas for excel (or word), the format is like this:
oActiveBook.SaveAs FileName:=App.Path + "\myExcelFile.xlsx"
but you will have to add Microsoft's Excel Library to your project, and set a few variables (like oActiveBook in the above line, amongst others)....google 'visual basic 6' excel, and you will find MANY examples.
here is a sample i did not include you saving code becaus i do not know how you want to save
Code:Private Sub Command1_Click()
Dim FileName As String
On Error GoTo ErrHandler
FileName = "C:\ScreenShot.bmp" 'Write file path here
If Dir(FileName) <> "" Then
If MsgBox("File '" & FileName & "' already exits, would you like to replace the file?", vbExclamation + vbYesNo, "Replace File?") = vbYes Then
Kill FileName
Do Until Dir(FileName) = "" 'Do Until File does not exist
DoEvents
Loop
Debug.Print "Deleted File... Now Replacing"
'Here would be the saving function (save file)
Debug.Print "File Saved!"
End If
Else
Debug.Print "Does not Exist"
End If
Exit Sub
ErrHandler:
MsgBox Err.Description
End Sub