|
-
Jan 24th, 2006, 02:29 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Word Save
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
Last edited by Hack; Jan 25th, 2006 at 09:33 AM.
-
Jan 24th, 2006, 02:30 PM
#2
Re: Word Save
Are you doing this from VB6 or Word VBA?
-
Jan 24th, 2006, 02:58 PM
#3
Thread Starter
Addicted Member
-
Jan 24th, 2006, 05:33 PM
#4
Re: Word Save
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
-
Jan 25th, 2006, 06:45 AM
#5
Thread Starter
Addicted Member
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
|