Results 1 to 5 of 5

Thread: [RESOLVED] Word Save

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2003
    Posts
    233

    Resolved [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.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Word Save

    Are you doing this from VB6 or Word VBA?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2003
    Posts
    233

    Re: Word Save

    Thank's Hack

    From VB6

  4. #4
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Word Save

    Try something like this..
    VB Code:
    1. Private Sub Command1_Click()
    2. Dim ws              As Object
    3. Dim FileName        As String
    4. Dim TempFileName    As String
    5.  
    6.     Set ws = CreateObject("Word.Application")
    7.     ws.Visible = False
    8.     ws.Documents.Add
    9.    
    10.     FileName = "C:\WordDoc"
    11.     TempFileName = FileName & ".doc"
    12.    
    13.     For i = 1 To 100 ' 100 tries (just to avoid using a While Loop)
    14.         If Dir(TempFileName) <> vbNullString Then
    15.             TempFileName = FileName & CStr(i) & ".doc"
    16.         Else
    17.             Exit For
    18.         End If
    19.     Next
    20.     'If you want to remove the reference to Word Library in your project,
    21.     'you'll need to define all constants used..
    22.     ws.ActiveDocument.SaveAs FileName:=TempFileName, FileFormat:= _
    23.     wdFormatDocument, LockComments:=False, Password:="", AddToRecentFiles:= _
    24.     True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:= _
    25.     False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
    26.     SaveAsAOCELetter:=False
    27.    
    28.     ws.Documents.Close
    29.     ws.Application.Quit
    30.     Set ws = Nothing
    31. End Sub

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Nov 2003
    Posts
    233

    Re: Word Save

    Thank's jcis

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width