Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 12-13-2018, 08:43 PM
Yong Xiang Yong Xiang is offline How do I code bookmark globally for different template? Windows 7 32bit How do I code bookmark globally for different template? Office 2016
Novice
How do I code bookmark globally for different template?
 
Join Date: Dec 2018
Posts: 9
Yong Xiang is on a distinguished road
Default

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 
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I code bookmark globally for different template? Field Code: Show a value only if bookmark is not empty Cosmo Word 7 08-24-2018 01:46 PM
How do I code bookmark globally for different template? VBA Code to Access Building Block Template in Word 2013 Startup folder rdross51 Word VBA 2 06-01-2016 07:05 PM
Find Bookmark, move to bookmark, execute code, repeat raymm3852 Word VBA 10 04-15-2016 06:21 PM
How do I code bookmark globally for different template? VBA Code in template does not run in new document highrise955 Word VBA 4 03-06-2016 04:48 PM
How do I code bookmark globally for different template? Visual basic code for Word 2003 template KateAus Word VBA 4 09-09-2012 08:40 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:33 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft