Whether there is any 'inappropriate' code really depends on whether the document contains the things referred to in, for example ".Fields(3).Result" and ".Variables.Item("Date1").Value". Combined, the code could become:
Code:
Sub AutoNew()
Dim InvoiceFile As String, InvNum As String, myDate As Date, StrPath As String
'Set the file save path.
StrPath = "G:\Sales Invoice\"
'Save ini file in the Word startup folder.
InvoiceFile = Options.DefaultFilePath(wdStartupPath) & "\Invoice.ini"
'or, by using the following line, the Workgroup folder
'InvoiceFile = Options.DefaultFilePath(wdWorkgroupTemplatesPath) & "\Invoice.ini"
InvNum = System.PrivateProfileString(InvoiceFile, "InvoiceNumber", "InvNum")
'If there is no InvoiceNumber reference in the ini file
'Create one and set the number to 1, otherwise increment the number
If InvNum = "" Then
InvNum = 1
Else
InvNum = InvNum + 1
End If
System.PrivateProfileString(InvoiceFile, "InvoiceNumber", "InvNum") = InvNum
With ActiveDocument
'Set the starting date with the value of a field
myDate = .Fields(3).Result
.Variables("Date1").Value = Format(myDate + 7, "dd MMMM yyyy")
.CustomDocumentProperties("InvNum") = InvNum
.Fields.Update
.SaveAs2 FileName:=StrPath & "Invoice #" & InvNum, Fileformat:=wdFormatPDF
End With
End Sub
However, I doubt the validity of saving a document immediately it's created (and before you'd actually input any relevant invoice content) as a PDF.