Hi
How to saveas the word doc name + 1
My .doc name test for the first save and for the second save i want to be test1 if test .doc is exit
Thank's
Added [RESOLVED] to thread title and green "resolved" checkmark - Hack
Printable View
Hi
How to saveas the word doc name + 1
My .doc name test for the first save and for the second save i want to be test1 if test .doc is exit
Thank's
Added [RESOLVED] to thread title and green "resolved" checkmark - Hack
Are you doing this from VB6 or Word VBA?
Thank's Hack
From VB6
Try something like this..
VB Code:
Private Sub Command1_Click() Dim ws As Object Dim FileName As String Dim TempFileName As String Set ws = CreateObject("Word.Application") ws.Visible = False ws.Documents.Add FileName = "C:\WordDoc" TempFileName = FileName & ".doc" For i = 1 To 100 ' 100 tries (just to avoid using a While Loop) If Dir(TempFileName) <> vbNullString Then TempFileName = FileName & CStr(i) & ".doc" Else Exit For End If Next 'If you want to remove the reference to Word Library in your project, 'you'll need to define all constants used.. ws.ActiveDocument.SaveAs FileName:=TempFileName, FileFormat:= _ wdFormatDocument, LockComments:=False, Password:="", AddToRecentFiles:= _ True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:= _ False, SaveNativePictureFormat:=False, SaveFormsData:=False, _ SaveAsAOCELetter:=False ws.Documents.Close ws.Application.Quit Set ws = Nothing End Sub
Thank's jcis