From: Karl E. Peterson on
LA Lawyer wrote:
> I want to assign some variables in Access, then open Word and have those
> variables available to me the entire time that I am in that session of Word,
> even if open another document.

Are you attempting to automate Word from Access? Or are you just
starting Word up, and wanting it to bootstrap these values somehow?

--
..NET: It's About Trust!
http://vfred.mvps.org


From: LA Lawyer on
The latter: I am starting Word through Access VBA and then I want to use
those values in Word throughout the session, even if I left the
ActiveDocument.
"Karl E. Peterson" <karl(a)exmvps.org> wrote in message
news:%23nBWvAs0KHA.6104(a)TK2MSFTNGP06.phx.gbl...
> LA Lawyer wrote:
>> I want to assign some variables in Access, then open Word and have those
>> variables available to me the entire time that I am in that session of
>> Word, even if open another document.
>
> Are you attempting to automate Word from Access? Or are you just starting
> Word up, and wanting it to bootstrap these values somehow?
>
> --
> .NET: It's About Trust!
> http://vfred.mvps.org
>
>


From: Karl E. Peterson on
LA Lawyer wrote:
>>> I want to assign some variables in Access, then open Word and have those
>>> variables available to me the entire time that I am in that session of
>>> Word, even if open another document.
>>
>> Are you attempting to automate Word from Access? Or are you just starting
>> Word up, and wanting it to bootstrap these values somehow?
>
> The latter: I am starting Word through Access VBA and then I want to use
> those values in Word throughout the session, even if I left the
> ActiveDocument.

In that case, I'd highly recommend you look at some form of cached
persistence. Maybe writing the values to an INI file or Registry key
that both applications are aware of?

If those aren't viable answers, for some reason or another, we could
look at some totally hacky possibilities. (Like sending Word bogus
command line arguments, then reading those with the API.) But staying
conventional will be a happier path to follow, if you can.

--
..NET: It's About Trust!
http://vfred.mvps.org


From: LA Lawyer on
I have been trying, at the same time, to use custom and builtin properties
from Access (automating Word) as follows (this doesn't give me an error
message; it simply doesn't work):

Public Function AddWordCustomProperty(NameofCustomProperty As String,
ValueofCustomProperty As String, Optional TypeOfVariableIfNotString As
String)
Select Case TypeOfVariableIfNotString
Case "Boolean"
TypeOfVariableIfNotString = "msoPropertyBoolean"
Case "Date"
TypeOfVariableIfNotString = "msoPropertyDate"
Case "Number"
TypeOfVariableIfNotString = "msoPropertyNumber"
Case Else
TypeOfVariableIfNotString = "msoPropertyString"
End Select
With ActiveDocument
If .BuiltInDocumentProperties.Exists(NameofCustomProperty) = True Then
.BuiltInDocumentProperties(NameofCustomProperty).Value =
ValueofCustomProperty
Else
.CustomDocumentProperties.Add _
Name:=NameofCustomProperty, LinkToContent:=False,
Value:=ValueofCustomProperty, Type:=TypeOfVariableIfNotString
End If
End With

Obviously, if I can save these in properties of the activedocument, then I
will be 90% of the way home.

"Karl E. Peterson" <karl(a)exmvps.org> wrote in message
news:OY9CBLs0KHA.348(a)TK2MSFTNGP02.phx.gbl...
> LA Lawyer wrote:
>>>> I want to assign some variables in Access, then open Word and have
>>>> those variables available to me the entire time that I am in that
>>>> session of Word, even if open another document.
>>>
>>> Are you attempting to automate Word from Access? Or are you just
>>> starting Word up, and wanting it to bootstrap these values somehow?
>>
>> The latter: I am starting Word through Access VBA and then I want to use
>> those values in Word throughout the session, even if I left the
>> ActiveDocument.
>
> In that case, I'd highly recommend you look at some form of cached
> persistence. Maybe writing the values to an INI file or Registry key that
> both applications are aware of?
>
> If those aren't viable answers, for some reason or another, we could look
> at some totally hacky possibilities. (Like sending Word bogus command
> line arguments, then reading those with the API.) But staying
> conventional will be a happier path to follow, if you can.
>
> --
> .NET: It's About Trust!
> http://vfred.mvps.org
>
>


From: Doug Robbins - Word MVP on
You could create document variables in the document.

ActiveDocument.Variables("variableName").Value = [something supplied by
Access"

Then you can display the content of the variable in a { DOCVARIABLE
variableName } field

or retrieve at any time by the use of

Dim strAccessValue as String (or whatever type of thing it is)

strAccessValue = ActiveDocument.Variables("variableName").Value

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"LA Lawyer" <hkapp(a)kapplaw.com> wrote in message
news:#vbDfQs0KHA.6068(a)TK2MSFTNGP04.phx.gbl...
> I have been trying, at the same time, to use custom and builtin properties
> from Access (automating Word) as follows (this doesn't give me an error
> message; it simply doesn't work):
>
> Public Function AddWordCustomProperty(NameofCustomProperty As String,
> ValueofCustomProperty As String, Optional TypeOfVariableIfNotString As
> String)
> Select Case TypeOfVariableIfNotString
> Case "Boolean"
> TypeOfVariableIfNotString = "msoPropertyBoolean"
> Case "Date"
> TypeOfVariableIfNotString = "msoPropertyDate"
> Case "Number"
> TypeOfVariableIfNotString = "msoPropertyNumber"
> Case Else
> TypeOfVariableIfNotString = "msoPropertyString"
> End Select
> With ActiveDocument
> If .BuiltInDocumentProperties.Exists(NameofCustomProperty) = True Then
> .BuiltInDocumentProperties(NameofCustomProperty).Value =
> ValueofCustomProperty
> Else
> .CustomDocumentProperties.Add _
> Name:=NameofCustomProperty, LinkToContent:=False,
> Value:=ValueofCustomProperty, Type:=TypeOfVariableIfNotString
> End If
> End With
>
> Obviously, if I can save these in properties of the activedocument, then I
> will be 90% of the way home.
>
> "Karl E. Peterson" <karl(a)exmvps.org> wrote in message
> news:OY9CBLs0KHA.348(a)TK2MSFTNGP02.phx.gbl...
>> LA Lawyer wrote:
>>>>> I want to assign some variables in Access, then open Word and have
>>>>> those variables available to me the entire time that I am in that
>>>>> session of Word, even if open another document.
>>>>
>>>> Are you attempting to automate Word from Access? Or are you just
>>>> starting Word up, and wanting it to bootstrap these values somehow?
>>>
>>> The latter: I am starting Word through Access VBA and then I want to use
>>> those values in Word throughout the session, even if I left the
>>> ActiveDocument.
>>
>> In that case, I'd highly recommend you look at some form of cached
>> persistence. Maybe writing the values to an INI file or Registry key
>> that both applications are aware of?
>>
>> If those aren't viable answers, for some reason or another, we could look
>> at some totally hacky possibilities. (Like sending Word bogus command
>> line arguments, then reading those with the API.) But staying
>> conventional will be a happier path to follow, if you can.
>>
>> --
>> .NET: It's About Trust!
>> http://vfred.mvps.org
>>
>>
>
>