View Single Post
 
Old 08-07-2018, 08:50 AM
staicumihai staicumihai is offline Windows 7 32bit Office 2010 32bit
Advanced Beginner
 
Join Date: Dec 2015
Posts: 33
staicumihai is on a distinguished road
Default Macro to save Word 2007 document using info from Quick Parts

Hi guys,

I have a macro below that used to work in Microsoft Word 2010 and now that I have installed Microsoft Word 2007 it doesnt work to save the document with the new name as docx.

I get an error on this line

Code:
ActiveDocument.SaveAs2 strDrive & fisword & ".docx"
Do you know what I should modify to make it work ?

Code:
Option Explicit
Sub FPVS()
Dim fisword As String
Dim FOLDER 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 nume1 As String
Dim prenume1 As String
Dim prenume11 As String

Const strDrive As String = "D:\MIHAI\FPVS\"
raport = Trim(ActiveDocument.BuiltInDocumentProperties("Title").Value)
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, " ", "")
nume1 = ActiveDocument.BuiltInDocumentProperties("Author").Value

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
fisword = "R" & raport & nrfpvs & "-" & anfpvs & " " & nr & " " & marca1(0)
FOLDER = "FPVS" & " " & nrfpvs & "-" & anfpvs


ActiveDocument.SaveAs2 strDrive & fisword & ".docx"
ActiveDocument.SaveAs2 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 no save
.Documents(1).Close SaveChanges:=wdSaveChanges
Loop
'Quit Word save
.Quit SaveChanges:=wdSaveChanges
End With
Exit Sub
End Sub
Reply With Quote