![]() |
#1
|
|||
|
|||
![]()
*******************************************
**************** 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 ![]() |
#2
|
|||
|
|||
![]()
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 |
#3
|
|||
|
|||
![]()
XmisterIS, what was your obvious solution?
|
![]() |
|
![]() |
||||
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 |
![]() |
riff88 | Word | 1 | 09-18-2012 03:39 AM |
![]() |
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 |