I've wanted to be able to do this for the longest time - this macro inserts the file number in the comments box of the Word file properties - you could change it to add it to a header/footer, etc. If a query comes back on a typed document, I want to be able to easily find the associated sound file. Some of our authors dictate lots of sound files, but they want them typed as one document - in this case, the macro adds a comma and then the next sound file number.
Function RegKeyRead(myRegKey As String) As String
Dim myWS As Object
'using Windows Scripting (WS) because VB get settings can
'only examine a small area of the registry
Set myWS = CreateObject("WScript.Shell")
RegKeyRead = myWS.RegRead(myRegKey)
End Function
Sub GetCurrentFileName()
Dim myRegKey As String
myRegKey = "HKEY_CURRENT_USER\Software\NCH Swift Sound\Scribe\Settings\currentfile"
'this calls the RegKeyRead function and passes it the registry edit info
myValue = RegKeyRead(myRegKey)
'the next line reads the dictation number from the .dat file
myFileNumber = System.PrivateProfileString(myValue, "file", "number")
'if the comments box is currently empty, this inserts the file number. If it isn't
'empty, it takes the current contents, adds a comma, a space, and the file number
If ActiveDocument.BuiltInDocumentProperties("Comments") = "" Then
ActiveDocument.BuiltInDocumentProperties("Comments") = myFileNumber
Else
myNewComment = ActiveDocument.BuiltInDocumentProperties("Comments") & ", " & myFileNumber
ActiveDocument.BuiltInDocumentProperties("Comments") = myNewComment
End If
End Sub