View Single Post
 
Old 08-30-2017, 04:02 AM
vicmar vicmar is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Aug 2017
Posts: 24
vicmar is on a distinguished road
Default

Hi gmayor

I figure it already but the problem is when i save as and change the filename its not updating.
This the code I used:
Code:
Sub AutoOpen()
Dim strRef, strDisp, strSht, strRev As String
Dim vRef, vDisp, vSht, vRev As Variant
    With ActiveDocument
        strRef = Left(.Name, InStrRev(.Name, ".") - 1)
        vRef = Split(strRef, "-")
        strRef = "KR-A359-STR-" & vRef(1) & "-" & vRef(2) & "-" & vRef(3) & "-" & vRef(4)
        .Variables("varRef").Value = strRef
        .Fields.Update
    End With
    With ActiveDocument
        strDisp = Left(.Name, InStrRev(.Name, ".") - 1)
        vDisp = Split(strDisp, "-")
        strDisp = "KR-A359-STR-" & vDisp(1)
        .Variables("varDisp").Value = strDisp
        .Fields.Update
    End With
    With ActiveDocument
        strSht = Left(.Name, InStrRev(.Name, ".") - 1)
        vSht = Split(strSht, "-")
        strSht = vSht(3) & "-" & vSht(4)
        .Variables("varSht").Value = strSht
        .Fields.Update
    End With
    With ActiveDocument
        strRev = Left(.Name, InStrRev(.Name, ".") - 1)
        vRev = Split(strRev, "-")
        strRev = "STR-" & vRev(1) & "-" & vRev(2) & "-" & vRev(3)
        .Variables("varRev").Value = strRev
        .Fields.Update
    End With
End Sub
Reply With Quote