|
|
| Next: Block viewing of distribution email list when sen.. |
| Author |
Message |
Abel MacAdam External

Since: Mar 27, 2009 Posts: 8
|
Posted: Fri Mar 27, 2009 8:16 am Post subject: Show form again, filled with docvariables Archived from groups: microsoft>public>word>vba>userforms (more info?) |
|
|
Hi,
When the user has filled in all fields, and clicked the OK button,
everything filled in will be displayed in the document. That works fine for
me.
But what if the document is reviewed by others, and I need to incorporate
their comments in the text in the docvariables? I need to show the form
again, but now with the content of the docvariables filled in in the text
fields. I can then change those fields they had comments about.
I think I have reading the docvariables into the textfields whipped. But I
need to know what I need to do to display the form again. Anyone a suggestion?
TIA,
Abel |
|
| Back to top |
|
 |
Doug Robbins - Word MVP o External

Since: Feb 24, 2009 Posts: 51
|
Posted: Fri Mar 27, 2009 7:10 pm Post subject: Re: Show form again, filled with docvariables [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
You need to run a macro that has the command in it to Show the form.
--
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
"Abel MacAdam" <AbelMacAdam.RemoveThis@discussions.microsoft.com> wrote in message
news:09198DC2-BAF5-43EB-B1BD-98F946C15E58@microsoft.com...
> Hi,
>
> When the user has filled in all fields, and clicked the OK button,
> everything filled in will be displayed in the document. That works fine
> for
> me.
>
> But what if the document is reviewed by others, and I need to incorporate
> their comments in the text in the docvariables? I need to show the form
> again, but now with the content of the docvariables filled in in the text
> fields. I can then change those fields they had comments about.
>
> I think I have reading the docvariables into the textfields whipped. But I
> need to know what I need to do to display the form again. Anyone a
> suggestion?
>
> TIA,
> Abel |
|
| Back to top |
|
 |
Jay Freedman External

Since: Mar 17, 2004 Posts: 2955
|
Posted: Fri Mar 27, 2009 9:42 pm Post subject: Re: Show form again, filled with docvariables [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
In addition, either the macro that shows the userform or the UserForm_Initialize
procedure within the userform has to assign the value of each docvariable to the
..Text property of the corresponding text box of the userform. This is just the
reverse of what the macro/userform does to populate the docvariables. Example:
txtName.Text = ActiveDocument.Variables("name").Value
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all
may benefit.
On Sat, 28 Mar 2009 07:51:14 +1000, "Doug Robbins - Word MVP on
news.microsoft.com" <dkr DeleteThis @REMOVECAPSmvps.org> wrote:
>You need to run a macro that has the command in it to Show the form.
>
>--
>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
>
>"Abel MacAdam" <AbelMacAdam DeleteThis @discussions.microsoft.com> wrote in message
>news:09198DC2-BAF5-43EB-B1BD-98F946C15E58@microsoft.com...
>> Hi,
>>
>> When the user has filled in all fields, and clicked the OK button,
>> everything filled in will be displayed in the document. That works fine
>> for
>> me.
>>
>> But what if the document is reviewed by others, and I need to incorporate
>> their comments in the text in the docvariables? I need to show the form
>> again, but now with the content of the docvariables filled in in the text
>> fields. I can then change those fields they had comments about.
>>
>> I think I have reading the docvariables into the textfields whipped. But I
>> need to know what I need to do to display the form again. Anyone a
>> suggestion?
>>
>> TIA,
>> Abel
> |
|
| Back to top |
|
 |
Dolfje External

Since: Mar 30, 2009 Posts: 1
|
Posted: Mon Mar 30, 2009 4:21 am Post subject: RE: Show form again, filled with docvariables [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
Abel,
as I understand your question you want to start the userform with the
textbox(es) filled with the value of document variables.
You can use this:
Private Sub UserForm_Initialize()
Me.TextBox1.Value = ActiveDocument.Variables("Name_of_variable").Value
End Sub
====================================================
"Abel MacAdam" wrote:
> Hi,
>
> When the user has filled in all fields, and clicked the OK button,
> everything filled in will be displayed in the document. That works fine for
> me.
>
> But what if the document is reviewed by others, and I need to incorporate
> their comments in the text in the docvariables? I need to show the form
> again, but now with the content of the docvariables filled in in the text
> fields. I can then change those fields they had comments about.
>
> I think I have reading the docvariables into the textfields whipped. But I
> need to know what I need to do to display the form again. Anyone a suggestion?
>
> TIA,
> Abel |
|
| Back to top |
|
 |
Abel MacAdam External

Since: Mar 27, 2009 Posts: 8
|
Posted: Fri Apr 10, 2009 6:14 am Post subject: RE: Show form again, filled with docvariables [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
Hi all,
It's ten days since I could work on this problem. I took your suggestions in
consideration, but could not get anything working.
In my VB editor I have a form (UserForm1), and two pieces of code. The
following piece of code comes from my 'Main (Code)'.
Sub ChangeFieldsContents()
With oVars
.Item("afield").Value = oVars("afield").Value
End With
CallUF
End Sub
Sub CallUF()
Dim oFrm As UserForm1
Dim oVars As Word.Variables
Dim pString As String
Dim oRng As Range
Dim i As Long
Set oVars = ActiveDocument.Variables
Set oFrm = New UserForm1
With oFrm
.Show
If .boolProceed Then
oVars("afield") = .afield.Text
UpdateFormFields
End If
End With
Unload oFrm
Set oFrm = Nothing
Set oVars = Nothing
Set oRng = Nothing
End Sub
The form is displayed OK, but the contents are not shown. Me thinks it is
something small I'm forgetting. So if anyone of you sees what I could try, I
would be obliged.
BTW, I tried Dolfs suggestion too. I saw the object Me was only known in the
code connected to UserForm1 ('UserForm1 (Code)'). So I put it there (as the
Main (Code) generated an error about Me not being known):
Sub ChangeFieldsContents()
Me.aField,Value = ActiveDocument.Variables("aField").Value
End Sub.
It did not work either.
Abel
"Dolfje" wrote:
> Abel,
> as I understand your question you want to start the userform with the
> textbox(es) filled with the value of document variables.
>
> You can use this:
> Private Sub UserForm_Initialize()
> Me.TextBox1.Value = ActiveDocument.Variables("Name_of_variable").Value
> End Sub
>
> ====================================================
> "Abel MacAdam" wrote:
>
> > Hi,
> >
> > When the user has filled in all fields, and clicked the OK button,
> > everything filled in will be displayed in the document. That works fine for
> > me.
> >
> > But what if the document is reviewed by others, and I need to incorporate
> > their comments in the text in the docvariables? I need to show the form
> > again, but now with the content of the docvariables filled in in the text
> > fields. I can then change those fields they had comments about.
> >
> > I think I have reading the docvariables into the textfields whipped. But I
> > need to know what I need to do to display the form again. Anyone a suggestion?
> >
> > TIA,
> > Abel |
|
| Back to top |
|
 |
Abel MacAdam External

Since: Mar 27, 2009 Posts: 8
|
Posted: Fri Apr 10, 2009 6:59 am Post subject: RE: Show form again, filled with docvariables [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
I just got a little bit further in my quest to (re)open the form:
Sub ChangeFieldsContents()
Set oVars = ActiveDocument.Variables
With oVars
.Item("aField").Value = oVars("aField").Value
End With
UserForm1.Show
' And then what? CallUF? or UpdateFormFields()?
End Sub
Sub CallUF()
Dim oFrm As UserForm1
Dim oVars As Word.Variables
Dim pString As String
Dim oRng As Range
Dim i As Long
Set oVars = ActiveDocument.Variables
Set oFrm = New UserForm1
With oFrm
..Show
If .boolProceed Then
oVars("afield") = .afield.Text
UpdateFormFields
End If
End With
Unload oFrm
Set oFrm = Nothing
Set oVars = Nothing
Set oRng = Nothing
End Sub
Sub UpdateFormFields()
Dim pRange As Word.Range
Dim iLink As Long
iLink = ActiveDocument.Sections(1).Headers(1).Range.StoryType
For Each pRange In ActiveDocument.StoryRanges
Do
pRange.Fields.Update
Set pRange = pRange.NextStoryRange
Loop Until pRange Is Nothing
Next
End Sub
As it is, I get the code to read what was read. Only when the contents of
the form is changed the change is not found in the document.
Anyone a solution?
Abel
"Abel MacAdam" wrote:
> Hi all,
>
> It's ten days since I could work on this problem. I took your suggestions in
> consideration, but could not get anything working.
>
> In my VB editor I have a form (UserForm1), and two pieces of code. The
> following piece of code comes from my 'Main (Code)'.
> Sub ChangeFieldsContents()
> With oVars
> .Item("afield").Value = oVars("afield").Value
> End With
> CallUF
> End Sub
>
> Sub CallUF()
> Dim oFrm As UserForm1
> Dim oVars As Word.Variables
> Dim pString As String
> Dim oRng As Range
> Dim i As Long
> Set oVars = ActiveDocument.Variables
> Set oFrm = New UserForm1
> With oFrm
> .Show
> If .boolProceed Then
> oVars("afield") = .afield.Text
> UpdateFormFields
> End If
> End With
>
> Unload oFrm
> Set oFrm = Nothing
> Set oVars = Nothing
> Set oRng = Nothing
> End Sub
>
> The form is displayed OK, but the contents are not shown. Me thinks it is
> something small I'm forgetting. So if anyone of you sees what I could try, I
> would be obliged.
>
> BTW, I tried Dolfs suggestion too. I saw the object Me was only known in the
> code connected to UserForm1 ('UserForm1 (Code)'). So I put it there (as the
> Main (Code) generated an error about Me not being known):
> Sub ChangeFieldsContents()
> Me.aField,Value = ActiveDocument.Variables("aField").Value
> End Sub.
> It did not work either.
>
> Abel
>
>
> "Dolfje" wrote:
>
> > Abel,
> > as I understand your question you want to start the userform with the
> > textbox(es) filled with the value of document variables.
> >
> > You can use this:
> > Private Sub UserForm_Initialize()
> > Me.TextBox1.Value = ActiveDocument.Variables("Name_of_variable").Value
> > End Sub
> >
> > ====================================================
> > "Abel MacAdam" wrote:
> >
> > > Hi,
> > >
> > > When the user has filled in all fields, and clicked the OK button,
> > > everything filled in will be displayed in the document. That works fine for
> > > me.
> > >
> > > But what if the document is reviewed by others, and I need to incorporate
> > > their comments in the text in the docvariables? I need to show the form
> > > again, but now with the content of the docvariables filled in in the text
> > > fields. I can then change those fields they had comments about.
> > >
> > > I think I have reading the docvariables into the textfields whipped. But I
> > > need to know what I need to do to display the form again. Anyone a suggestion?
> > >
> > > TIA,
> > > Abel |
|
| Back to top |
|
 |
Doug Robbins - Word MVP o External

Since: Feb 24, 2009 Posts: 51
|
Posted: Fri Apr 10, 2009 7:10 pm Post subject: Re: Show form again, filled with docvariables [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
I do not know what you UpdateFormFields does. However if you want the
control on the userform to which the name afield is assigned to be
populated with the value that is stored in the afield document variable,
then you need to reverse
oVars("afield") = .afield.Text
and use
..afield.Text = oVars("afield").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
"Abel MacAdam" <AbelMacAdam.DeleteThis@discussions.microsoft.com> wrote in message
news:6106E825-27B7-4ED5-BEA5-2D7B4FFEEEDD@microsoft.com...
> Hi all,
>
> It's ten days since I could work on this problem. I took your suggestions
> in
> consideration, but could not get anything working.
>
> In my VB editor I have a form (UserForm1), and two pieces of code. The
> following piece of code comes from my 'Main (Code)'.
> Sub ChangeFieldsContents()
> With oVars
> .Item("afield").Value = oVars("afield").Value
> End With
> CallUF
> End Sub
>
> Sub CallUF()
> Dim oFrm As UserForm1
> Dim oVars As Word.Variables
> Dim pString As String
> Dim oRng As Range
> Dim i As Long
> Set oVars = ActiveDocument.Variables
> Set oFrm = New UserForm1
> With oFrm
> .Show
> If .boolProceed Then
> oVars("afield") = .afield.Text
> UpdateFormFields
> End If
> End With
>
> Unload oFrm
> Set oFrm = Nothing
> Set oVars = Nothing
> Set oRng = Nothing
> End Sub
>
> The form is displayed OK, but the contents are not shown. Me thinks it is
> something small I'm forgetting. So if anyone of you sees what I could try,
> I
> would be obliged.
>
> BTW, I tried Dolfs suggestion too. I saw the object Me was only known in
> the
> code connected to UserForm1 ('UserForm1 (Code)'). So I put it there (as
> the
> Main (Code) generated an error about Me not being known):
> Sub ChangeFieldsContents()
> Me.aField,Value = ActiveDocument.Variables("aField").Value
> End Sub.
> It did not work either.
>
> Abel
>
>
> "Dolfje" wrote:
>
>> Abel,
>> as I understand your question you want to start the userform with the
>> textbox(es) filled with the value of document variables.
>>
>> You can use this:
>> Private Sub UserForm_Initialize()
>> Me.TextBox1.Value = ActiveDocument.Variables("Name_of_variable").Value
>> End Sub
>>
>> ====================================================
>> "Abel MacAdam" wrote:
>>
>> > Hi,
>> >
>> > When the user has filled in all fields, and clicked the OK button,
>> > everything filled in will be displayed in the document. That works fine
>> > for
>> > me.
>> >
>> > But what if the document is reviewed by others, and I need to
>> > incorporate
>> > their comments in the text in the docvariables? I need to show the form
>> > again, but now with the content of the docvariables filled in in the
>> > text
>> > fields. I can then change those fields they had comments about.
>> >
>> > I think I have reading the docvariables into the textfields whipped.
>> > But I
>> > need to know what I need to do to display the form again. Anyone a
>> > suggestion?
>> >
>> > TIA,
>> > Abel |
|
| Back to top |
|
 |
Abel MacAdam External

Since: Mar 27, 2009 Posts: 8
|
Posted: Tue Apr 14, 2009 1:40 am Post subject: Re: Show form again, filled with docvariables [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
Hi Doug,
Thanks for taking the time to help me. Quoting Greg Maxey: "Those (document
variable, Abel) fields need to be updated to the new variable values. We
accomplished this by calling a separate procedure "UpdateFormFields" that
cycles through each storyrange in the document and updates the fields. "
My UpdateFormFields is:
Sub myUpdateFields()
Dim pRange As Word.Range
Dim iLink As Long
iLink = ActiveDocument.Sections(1).Headers(1).Range.StoryType
For Each pRange In ActiveDocument.StoryRanges
Do
pRange.Fields.Update
Set pRange = pRange.NextStoryRange
Loop Until pRange Is Nothing
Next
End Sub
But this was not resulting in what I was expecting. I'm still not really
getting what is happening in my code
Abel
"Doug Robbins - Word MVP on news.microsof" wrote:
> I do not know what you UpdateFormFields does. However if you want the
> control on the userform to which the name afield is assigned to be
> populated with the value that is stored in the afield document variable,
> then you need to reverse
>
> oVars("afield") = .afield.Text
>
> and use
>
> ..afield.Text = oVars("afield").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
>
> "Abel MacAdam" <AbelMacAdam.RemoveThis@discussions.microsoft.com> wrote in message
> news:6106E825-27B7-4ED5-BEA5-2D7B4FFEEEDD@microsoft.com...
> > Hi all,
> >
> > It's ten days since I could work on this problem. I took your suggestions
> > in
> > consideration, but could not get anything working.
> >
> > In my VB editor I have a form (UserForm1), and two pieces of code. The
> > following piece of code comes from my 'Main (Code)'.
> > Sub ChangeFieldsContents()
> > With oVars
> > .Item("afield").Value = oVars("afield").Value
> > End With
> > CallUF
> > End Sub
> >
> > Sub CallUF()
> > Dim oFrm As UserForm1
> > Dim oVars As Word.Variables
> > Dim pString As String
> > Dim oRng As Range
> > Dim i As Long
> > Set oVars = ActiveDocument.Variables
> > Set oFrm = New UserForm1
> > With oFrm
> > .Show
> > If .boolProceed Then
> > oVars("afield") = .afield.Text
> > UpdateFormFields
> > End If
> > End With
> >
> > Unload oFrm
> > Set oFrm = Nothing
> > Set oVars = Nothing
> > Set oRng = Nothing
> > End Sub
> >
> > The form is displayed OK, but the contents are not shown. Me thinks it is
> > something small I'm forgetting. So if anyone of you sees what I could try,
> > I
> > would be obliged.
> >
> > BTW, I tried Dolfs suggestion too. I saw the object Me was only known in
> > the
> > code connected to UserForm1 ('UserForm1 (Code)'). So I put it there (as
> > the
> > Main (Code) generated an error about Me not being known):
> > Sub ChangeFieldsContents()
> > Me.aField,Value = ActiveDocument.Variables("aField").Value
> > End Sub.
> > It did not work either.
> >
> > Abel
> >
> >
> > "Dolfje" wrote:
> >
> >> Abel,
> >> as I understand your question you want to start the userform with the
> >> textbox(es) filled with the value of document variables.
> >>
> >> You can use this:
> >> Private Sub UserForm_Initialize()
> >> Me.TextBox1.Value = ActiveDocument.Variables("Name_of_variable").Value
> >> End Sub
> >>
> >> ====================================================
> >> "Abel MacAdam" wrote:
> >>
> >> > Hi,
> >> >
> >> > When the user has filled in all fields, and clicked the OK button,
> >> > everything filled in will be displayed in the document. That works fine
> >> > for
> >> > me.
> >> >
> >> > But what if the document is reviewed by others, and I need to
> >> > incorporate
> >> > their comments in the text in the docvariables? I need to show the form
> >> > again, but now with the content of the docvariables filled in in the
> >> > text
> >> > fields. I can then change those fields they had comments about.
> >> >
> >> > I think I have reading the docvariables into the textfields whipped.
> >> > But I
> >> > need to know what I need to do to display the form again. Anyone a
> >> > suggestion?
> >> >
> >> > TIA,
> >> > Abel
>
>
> |
|
| Back to top |
|
 |
|
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
| |
|
|