Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-04-2014, 08:30 AM
XmisterIS XmisterIS is offline How to add a read-only unique ID to a Word 2007 document? Windows 7 64bit How to add a read-only unique ID to a Word 2007 document? Office 2007
Novice
How to add a read-only unique ID to a Word 2007 document?
 
Join Date: Sep 2013
Posts: 12
XmisterIS is on a distinguished road
Default How to add a read-only unique ID to a Word 2007 document?

*******************************************


**************** SOLVED *******************
*******************************************


I have written a macro which carries out the following tasks:

1) Extract some data from the document (the nature of data itself is irrelevant to this thread).

2) Using a simple REST process:
2.i) Upload the data to my webserver as JSON data via WinHTTPRequest.
2.ii) Retrieve the result as JSON data and decode it.

3) Upon success, the decoded JSON data will contain a field named "keycode", which contains a unique 40 character string (from a hashing algorithm) which uniquely identifies the source of the data (i.e. the document).

4) The keycode is then stored in a text content control in the document.

The trouble is that the user can edit the content control - I want the content control to be read-only so far as the end user is concerned, but I want read/write access to it in the VBA.

I cannot manually assign a keycode to the document prior to it's creation because I intend to serve the document on my website as a word template. (If every document had the same keycode, that would be kind of silly ...). Similarly, the keycode must be generated on the webserver (by PHP) because I do not want to expose the hashing algorithm.

If I cannot do what I want using a content control, what other options are there? Are there any obscure document attributes that I could use? Or any attributes that can only be modified from VBA?

*******************************************
**************** SOLVED *******************
*******************************************


I was just being dense ... and missed the obvious!!! I could blame it on my being very new to VBA ... but that would be a lame excuse
Reply With Quote
  #2  
Old 04-04-2014, 08:37 AM
Larry Sulky Larry Sulky is offline How to add a read-only unique ID to a Word 2007 document? Windows 7 64bit How to add a read-only unique ID to a Word 2007 document? Office 2010 64bit
Novice
 
Join Date: Mar 2014
Posts: 14
Larry Sulky is on a distinguished road
Default Document variable?

Would a Word document variable work for you? Document variables require VBA coding ability to discover and read. See more at http://support.microsoft.com/kb/306281, from which the following example was taken:
Code:
Sub GetSetDocVars()

   Dim fName As String
   fName = "Jeff Smith"
   ' Set contents of variable "fName" in a document using a document
   ' variable called "FullName".
   ActiveDocument.Variables.Add Name:="FullName", Value:=fName
   ' Retrieve the contents of the document variable.
   MsgBox ActiveDocument.Variables("FullName").Value

End Sub
Reply With Quote
  #3  
Old 04-04-2014, 08:39 AM
Larry Sulky Larry Sulky is offline How to add a read-only unique ID to a Word 2007 document? Windows 7 64bit How to add a read-only unique ID to a Word 2007 document? Office 2010 64bit
Novice
 
Join Date: Mar 2014
Posts: 14
Larry Sulky is on a distinguished road
Default

XmisterIS, what was your obvious solution?
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't open objects in read-only Word 2007 document Calab Word 6 04-07-2014 05:02 AM
How to add a read-only unique ID to a Word 2007 document? How do I check when my MS word document was last read? riff88 Word 1 09-18-2012 03:39 AM
How to add a read-only unique ID to a Word 2007 document? Macro to read word document harishankar.selvaraju Excel Programming 1 06-14-2012 03:48 AM
Document unique numbering / forms JamesF Word 0 11-22-2010 03:52 AM
Can't save word document in anything but read format Stuckie Word 0 01-21-2010 12:46 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:02 PM.


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