Consulting

Results 1 to 10 of 10

Thread: Word 2007 macro to save word as .Docx

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Word 2007 macro to save word as .Docx

    Hi, I have this code that saves my word document .docx with a specific name and also converts it to .doc
    Do you guys have any idea how i can modify the code so that it saves with docx extension instead of doc and also to delete the original file ?
    Thanks
    God Bless!

    Option Explicit
    
    Sub FPVS()
        Dim fisword As String
        Dim FOLDER As String
        Dim primit As String
        Dim cinci As String
        Dim cinci1 As String
        Dim raport As String
        Dim FPVS As String
        Dim nrfpvs As String
        Dim anfpvs As String
        Dim nr As String
        Dim MARCA As String
        Dim data As String
        Dim data1 As String
        Dim data2 As String
        Dim separate() As String
        Dim marca1() As String
        Dim pagubit As String
        Dim pagubit1() As String
        Dim pagubit2 As String
        Dim pagubit3 As String
        Dim separat1 As String
        Dim nume As String
        Dim prenume11 As String
        Dim pos1 As Integer
        Dim pos2 As Integer
        Const strDrive As String = "C:\MIHAI\DOC\ASIG\DOSARE"
        FPVS = ActiveDocument.BuiltInDocumentProperties("keywords").Value
        nr = Replace(Trim(ActiveDocument.BuiltInDocumentProperties("Company").Value), Chr(45), "")
        MARCA = ActiveDocument.BuiltInDocumentProperties("Comments").Value
        data = ActiveDocument.BuiltInDocumentProperties("Content status").Value
        cinci = Right(Replace(Trim(ActiveDocument.BuiltInDocumentProperties("keywords").Value), "/", ".") & Chr(32), 6)
        cinci1 = Replace(cinci, " ", "")
        separate = Split(FPVS, "/")
        nrfpvs = separate(0)
        anfpvs = separate(1)
        ' anfpvs = Right(anfpvs, 2)
        marca1 = Split(MARCA, " ")
        data1 = Left(data, Len(data) - 4)
        data2 = Right(data, Len(data) - 8)
        data = data1 & data2
         'primit = "FPVS" & " " & nrfpvs & "-" & anfpvs & " " & data & " " & "ecl" & " " & "Mihai"'
        fisword = "Rxxx_" & "FPVS" & " " & raport & nrfpvs & "-" & anfpvs & " " & nr & " " & MARCA
        FOLDER = "FPVS" & " " & nrfpvs & "-" & anfpvs
        ' Name strDrive & primit As strDrive & FOLDER
        ActiveDocument.SaveAs strDrive & fisword & ".docx"
        ActiveDocument.SaveAs FileName:=strDrive & "\" & fisword & ".doc", FileFormat:=wdFormatDocument
        ' ActiveDocument.ExportAsFixedFormat OutputFileName:=strDrive & fisword & ".pdf", _
        ' ExportFormat:=wdExportFormatPDF, _
        ' OpenAfterExport:=False, _
        ' OptimizeFor:=wdExportOptimizeForPrint, _
        ' Range:=wdExportAllDocument, From:=1, to:=1, _
        ' Item:=wdExportDocumentContent, _
        ' IncludeDocProps:=True, _
        ' KeepIRM:=True, _
        ' CreateBookmarks:=wdExportCreateHeadingBookmarks, _
        ' DocStructureTags:=True, _
        ' BitmapMissingFonts:=True, _
        ' UseISO19005_1:=False
        ' lbl_Exit:
        With Application
            .ScreenUpdating = False
            Loop Through open documents
            Do Until .Documents.Count = 0
                ' Close save
                .Documents(1).Close SaveChanges:=wdSaveChanges
            Loop
            ' Quit Word save
            .Quit SaveChanges:=wdSaveChanges
        End With
        Exit Sub
    End Sub
    Last edited by Aussiebear; 03-09-2025 at 08:46 PM.

Posting Permissions

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