View Single Post
 
Old 12-13-2018, 08:01 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Your terminology is not good. Bookmarks have a specific meaning in Word and you are using this word in a way that doesn't make sense.

It appears you are wanting to store the path to a specific folder. That can be done either by creating a constant at the top of the module or by using a function that each macro calls. The benefit of the function approach is that the code could then be made to adapt to the relative path (ie the files are always in the desktop folder but that actual path will vary for each user). Using a hardcoded constant, the code could be written as follows.
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
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote