-
Oct 27th, 2012, 07:30 AM
#1
Thread Starter
Junior Member
display replace confirmation message for word file
hi,
i want to pop up replace dialogue box for word file if file already exists at specified location.
thanks,
kk
-
Oct 27th, 2012, 07:59 AM
#2
Re: display replace confirmation message for word file
are you using FSO? If so, use the fileexists method.
Can we see some code?
-
Oct 27th, 2012, 08:14 AM
#3
Thread Starter
Junior Member
Re: display replace confirmation message for word file
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?
-
Oct 27th, 2012, 08:31 AM
#4
Re: display replace confirmation message for word 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.
-
Oct 27th, 2012, 08:44 AM
#5
Re: display replace confirmation message for word file
Actually instead of the FSO you should use the built in DIR$() method.
Code:
If Dir$(Filename)<>"" then
-
Oct 27th, 2012, 09:00 AM
#6
Re: display replace confirmation message for word file
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.
-
Oct 27th, 2012, 11:46 AM
#7
Re: display replace confirmation message for word file
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
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|