Group:  Microsoft Word ยป microsoft.public.word.vba.userforms
Thread: Clearing/reinitializing docvariables?

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Clearing/reinitializing docvariables?
"Thom" <thomcollins[ at ]hotmail.com> 02.09.2006 16:38:39
Before releasing my template to the user, I need to clear the
docvariables and reset the arrays. Is there a simple way of doing such
without copying the code to a new template? The userform has a couple
combo boxes which I populate for the user to select from. Now I want to
clear out all the testing data and start over.

Re: Clearing/reinitializing docvariables?
"Jean-Guy Marcil" <NoSpam[ at ]LeaveMeAlone> 02.09.2006 17:16:24
Thom was telling us:
Thom nous racontait que :

[Quoted Text]
> Before releasing my template to the user, I need to clear the
> docvariables and reset the arrays. Is there a simple way of doing such
> without copying the code to a new template? The userform has a couple
> combo boxes which I populate for the user to select from. Now I want
> to clear out all the testing data and start over.

For doc variables, you do not really need to clear them.
As soon as the user created a document, your code will overwrite them.

But, if you need to, try something like:

Dim myDocVar As Variables

For Each myDocVar In ThisDocument.Variables
myDocVar.Value = " "
Next

I use a space because if I had used "", this would have effectively deleted
the document variable.

I am not sure what you mean by
"reset the arrays"
What arrays?

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE[ at ]CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org


Re: Clearing/reinitializing docvariables?
"Thom" <thomcollins[ at ]hotmail.com> 02.09.2006 20:38:54

Jean-Guy Marcil wrote:
[Quoted Text]
> Thom was telling us:
> Thom nous racontait que :
>
> > Before releasing my template to the user, I need to clear the
> > docvariables and reset the arrays. Is there a simple way of doing such
> > without copying the code to a new template? The userform has a couple
> > combo boxes which I populate for the user to select from. Now I want
> > to clear out all the testing data and start over.
>
> For doc variables, you do not really need to clear them.
> As soon as the user created a document, your code will overwrite them.
>
> But, if you need to, try something like:
>
> Dim myDocVar As Variables
>
> For Each myDocVar In ThisDocument.Variables
> myDocVar.Value = " "
> Next
>
> I use a space because if I had used "", this would have effectively deleted
> the document variable.
>
> I am not sure what you mean by
> "reset the arrays"
> What arrays?
>
> --
> Salut!
> _______________________________________
> Jean-Guy Marcil - Word MVP
> jmarcilREMOVE[ at ]CAPSsympatico.caTHISTOO
> Word MVP site: http://www.word.mvps.org

Jean-Guy,

Thanks for the snipet, but think of it this way. I have lots of test
data in a template and now I want it all to go away.
Here is the userform initialize piece that loads the combo box.
For Each aVar In fMyTemplate.Variables
sVariableName = aVar.Name
If InStr(sVName, "Plac") > 0 Then
cbPlace.AddItem aVar.Value
cbPlace.List(cbPlace.ListCount - 1, 1) =
fMyTemplate.Variables("PLAC" + CStr(CInt(Mid(sVName, 5)))).Value
cbPlace.List(cbPlace.ListCount - 1, 2) =
fMyTemplate.Variables("Add1" + CStr(CInt(Mid(sVName, 5)))).Value
End If

And it still loads all previously entered data.

Re: Clearing/reinitializing docvariables?
Russ <drsN0SPAMmikle[ at ]hotmailD0Tcom.INVALID> 02.09.2006 21:43:53
Thom,

Didn't running Jean-Guy's macro effectively put a space character in each of
your currently attached template's variables? (that's what
ThisDocument.Variables references) After running his macro and you go into
'File | Properties menu, Custom tab' of a document loaded by the template,
what do you see? If you still see something other than spaces (which will
look like your variables name 'values' are empty), then you might be playing
with the wrong template or you may be still populating the variables via
test code (in which case you should delete or comment out that part of the
code).

[Quoted Text]
> Jean-Guy Marcil wrote:
>> Thom was telling us:
>> Thom nous racontait que :
>>
>>> Before releasing my template to the user, I need to clear the
>>> docvariables and reset the arrays. Is there a simple way of doing such
>>> without copying the code to a new template? The userform has a couple
>>> combo boxes which I populate for the user to select from. Now I want
>>> to clear out all the testing data and start over.
>>
>> For doc variables, you do not really need to clear them.
>> As soon as the user created a document, your code will overwrite them.
>>
>> But, if you need to, try something like:
>>
>> Dim myDocVar As Variables
>>
>> For Each myDocVar In ThisDocument.Variables
>> myDocVar.Value = " "
>> Next
>>
>> I use a space because if I had used "", this would have effectively deleted
>> the document variable.
>>
>> I am not sure what you mean by
>> "reset the arrays"
>> What arrays?
>>
>> --
>> Salut!
>> _______________________________________
>> Jean-Guy Marcil - Word MVP
>> jmarcilREMOVE[ at ]CAPSsympatico.caTHISTOO
>> Word MVP site: http://www.word.mvps.org
>
> Jean-Guy,
>
> Thanks for the snipet, but think of it this way. I have lots of test
> data in a template and now I want it all to go away.
> Here is the userform initialize piece that loads the combo box.
> For Each aVar In fMyTemplate.Variables
> sVariableName = aVar.Name
> If InStr(sVName, "Plac") > 0 Then
> cbPlace.AddItem aVar.Value
> cbPlace.List(cbPlace.ListCount - 1, 1) =
> fMyTemplate.Variables("PLAC" + CStr(CInt(Mid(sVName, 5)))).Value
> cbPlace.List(cbPlace.ListCount - 1, 2) =
> fMyTemplate.Variables("Add1" + CStr(CInt(Mid(sVName, 5)))).Value
> End If
>
> And it still loads all previously entered data.
>

--
Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

Re: Clearing/reinitializing docvariables?
Russ <drsN0SPAMmikle[ at ]hotmailD0Tcom.INVALID> 02.09.2006 22:11:51
Thom,

Something I noticed in your code below.
[Quoted Text]
> Thom,
>
> Didn't running Jean-Guy's macro effectively put a space character in each of
> your currently attached template's variables? (that's what
> ThisDocument.Variables references) After running his macro and you go into
> 'File | Properties menu, Custom tab' of a document loaded by the template,
> what do you see? If you still see something other than spaces (which will
> look like your variables name 'values' are empty), then you might be playing
> with the wrong template or you may be still populating the variables via
> test code (in which case you should delete or comment out that part of the
> code).
>
>> Jean-Guy Marcil wrote:
>>> Thom was telling us:
>>> Thom nous racontait que :
>>>
>>>> Before releasing my template to the user, I need to clear the
>>>> docvariables and reset the arrays. Is there a simple way of doing such
>>>> without copying the code to a new template? The userform has a couple
>>>> combo boxes which I populate for the user to select from. Now I want
>>>> to clear out all the testing data and start over.
>>>
>>> For doc variables, you do not really need to clear them.
>>> As soon as the user created a document, your code will overwrite them.
>>>
>>> But, if you need to, try something like:
>>>
>>> Dim myDocVar As Variables
>>>
>>> For Each myDocVar In ThisDocument.Variables
>>> myDocVar.Value = " "
>>> Next
>>>
>>> I use a space because if I had used "", this would have effectively deleted
>>> the document variable.
>>>
>>> I am not sure what you mean by
>>> "reset the arrays"
>>> What arrays?
>>>
>>> --
>>> Salut!
>>> _______________________________________
>>> Jean-Guy Marcil - Word MVP
>>> jmarcilREMOVE[ at ]CAPSsympatico.caTHISTOO
>>> Word MVP site: http://www.word.mvps.org
>>
>> Jean-Guy,
>>
>> Thanks for the snipet, but think of it this way. I have lots of test
>> data in a template and now I want it all to go away.
>> Here is the userform initialize piece that loads the combo box.
>> For Each aVar In fMyTemplate.Variables
>> sVariableName = aVar.Name

Are sVariableName and sVName the same variable? Are you declaring Option
Explicit at the top of your VBA project code to help detect any undeclared
variables?

>> If InStr(sVName, "Plac") > 0 Then
>> cbPlace.AddItem aVar.Value
>> cbPlace.List(cbPlace.ListCount - 1, 1) =
>> fMyTemplate.Variables("PLAC" + CStr(CInt(Mid(sVName, 5)))).Value
>> cbPlace.List(cbPlace.ListCount - 1, 2) =
>> fMyTemplate.Variables("Add1" + CStr(CInt(Mid(sVName, 5)))).Value
>> End If
>>
>> And it still loads all previously entered data.
>>

--
Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net