Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-24-2017, 03:44 AM
gmayor's Avatar
gmayor gmayor is offline Insert Filename automatically when open Windows 10 Insert Filename automatically when open Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

How about the following. Display varRef with a docvariable field.

Code:
Dim strRef As String
Dim vRef As Variant
    With ActiveDocument
        strRef = Left(.Name, InStrRev(.Name, ".") - 1)
        vRef = Split(strRef, "-")
        strRef = "RS-A589-" & vRef(1) & "-" & vRef(0) & "-" & vRef(2) & "-" & vRef(3)
        .Variables("varRef").Value = strRef
        .Fields.Update
    End With

__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Filename automatically when open How to insert Wildcards into Word 2011 Mac such as: \$Filename\ peterspiano Word 4 06-29-2015 05:13 AM
Excel connot open file (filename) xlsx dengeorge6 Excel 0 12-12-2014 01:36 AM
Insert Filename automatically when open A macro that can insert FILENAME, sendkeys CTRL ALT T, paste clipboard, and nextline kyjac85 Word VBA 13 09-20-2012 05:00 PM
Insert Filename automatically when open How to insert current date into default filename ? czomberzdaniela Word 1 12-27-2011 07:18 PM
Macro for automatically adding filename without .doc RPM7 Word VBA 0 04-29-2010 01:43 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:46 AM.


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