View Single Post
 
Old 04-04-2014, 08:30 AM
XmisterIS XmisterIS is offline Windows 7 64bit Office 2007
Novice
 
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