Thanks, I'm still new to VBA didn't know that I can set a hardcoded constant like this.
I have tried your code but there is one error saying that couldn't find my file? Runtime error '5174'
at Selection.InsertFile FileName:=sPath & sFile, ConfirmConversions:=False,
code :
PHP Code:
Function InsertAFile(sFile As String)
Dim sPath as String
sPath = "C:\Users\YongX\Desktop\"
Selection.InsertFile FileName:=sPath & sFile, ConfirmConversions:=False,
Link:=False, Attachment:=False
Selection.TypeBackspace
End Function
Sub Add_HT_PD()
InsertAFile "HT PD.docx"
End Sub
Sub Add_HT_US()
InsertAFile "HT US.docx"
End Sub
Sub Add_TF_PD()
InsertAFile "TF PD.docx"
End Sub
Sub Add_TF_US()
InsertAFile "TF US.docx"
End Sub
Sub Add_HT()
InsertAFile "HT.docx"
End Sub
Sub Add_LT()
InsertAFile "LT.docx"
End Sub
Sub Update_Fields()
Application.ScreenUpdating = False
ActiveDocument.PrintPreview
ActiveDocument.ClosePrintPreview
Application.ScreenUpdating = True
End Sub