|
|
| Next: Problem with Sumproduct... |
| Author |
Message |
Abel MacAdam External

Since: Mar 27, 2009 Posts: 8
|
Posted: Fri May 08, 2009 1:37 am Post subject: After form execution: Strange characters in 2007 (II) Archived from groups: microsoft>public>word>vba>userforms (more info?) |
|
|
Hello,
This is a problem that is slightly different from the one I posted earlier.
As I had a follow up question in that post, and did not want to confuse the
issue, I thought it wiser to make a new post for this related problem.
I have text field in my form which allows multiple paragraphs. These
multiple paragraphs should appear as multiple paragraphs in the document. But
instead of multiple paragraphs I get one line. It looks like:
--form------------------
This is my first line.
<>
<>This is my second line.
<>
<>This is a third line
--end form-------------
It appears as
--document------------
his is my first line.<><><><>This is my second line.<><><><>This is a third
line
--end document-------
I thought I had it covered by adding a "Replace(fString, vbCr, "")" in my
code. It did not work out as expected (the first field comes out as described
above, the second field comes out as expected, but then as plain-old-text,
not as field with contents).
Does anyone know what I can do?
Abel
The code I use to get the splendid but unexpected result described above:
--Code----
Sub CallUF()
Dim oFrm As myForm
Dim oVars As Word.Variables
Dim pString As String
Dim oRng As Range
Dim i As Long
Set oVars = ActiveDocument.Variables
Set oFrm = New myForm
With oFrm
..Show
If .boolProceed Then
oVars("contractnumber") = .contractnumber.Text
oVars("customer") = .customer.Text
oVars("cust_service") = .cust_service.Text
oVars("webserver_number") = .webserver_number.Text
oVars("webserver_hostname") = .webserver_hostname.Text
oVars("databaseserver_number") = .databaseserver_number.Text
oVars("databaseserver_hostname") = .databaseserver_hostname.Text
UpdateFormVelden
End If
End With
Dim aField As Field
Dim fCode As Range
Dim fString As String
For Each aField In ActiveDocument.Fields
Set fCode = aField.Code
If InStr(fCode, "first_field") > 0 Or InStr(fCode, "second_field") > 0 Then
fString = aField.Result
aField.Delete
fCode.Text = Replace(fString, vbCr, "")
For i = 1 To fCode.Paragraphs.Count
With fCode.Paragraphs(i)
..LeftIndent = InchesToPoints(0.25)
..FirstLineIndent = InchesToPoints(-0.25)
End With
Next i
End If
Next aField
Unload oFrm
Set oFrm = Nothing
Set oVars = Nothing
Set oRng = Nothing
End Sub
---\ Code ---- |
|
| Back to top |
|
 |
Doug Robbins - Word MVP External

Since: Jul 14, 2006 Posts: 2665
|
Posted: Fri May 08, 2009 8:10 am Post subject: Re: After form execution: Strange characters in 2007 (II) [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
Sorry, I probably should have said to use Replace([your string], Chr(10),
"")
--
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:D04BA9AD-6D67-473B-A12A-F030E36B6986@microsoft.com...
> Hello,
>
> This is a problem that is slightly different from the one I posted
> earlier.
> As I had a follow up question in that post, and did not want to confuse
> the
> issue, I thought it wiser to make a new post for this related problem.
>
> I have text field in my form which allows multiple paragraphs. These
> multiple paragraphs should appear as multiple paragraphs in the document.
> But
> instead of multiple paragraphs I get one line. It looks like:
>
> --form------------------
> This is my first line.
> <>
> <>This is my second line.
> <>
> <>This is a third line
> --end form-------------
>
> It appears as
> --document------------
> his is my first line.<><><><>This is my second line.<><><><>This is a
> third
> line
> --end document-------
>
> I thought I had it covered by adding a "Replace(fString, vbCr, "")" in my
> code. It did not work out as expected (the first field comes out as
> described
> above, the second field comes out as expected, but then as plain-old-text,
> not as field with contents).
>
> Does anyone know what I can do?
>
> Abel
>
> The code I use to get the splendid but unexpected result described above:
> --Code----
> Sub CallUF()
> Dim oFrm As myForm
> Dim oVars As Word.Variables
> Dim pString As String
> Dim oRng As Range
> Dim i As Long
> Set oVars = ActiveDocument.Variables
> Set oFrm = New myForm
> With oFrm
> .Show
> If .boolProceed Then
> oVars("contractnumber") = .contractnumber.Text
> oVars("customer") = .customer.Text
> oVars("cust_service") = .cust_service.Text
> oVars("webserver_number") = .webserver_number.Text
> oVars("webserver_hostname") = .webserver_hostname.Text
> oVars("databaseserver_number") = .databaseserver_number.Text
> oVars("databaseserver_hostname") = .databaseserver_hostname.Text
> UpdateFormVelden
> End If
> End With
>
> Dim aField As Field
> Dim fCode As Range
> Dim fString As String
>
> For Each aField In ActiveDocument.Fields
> Set fCode = aField.Code
> If InStr(fCode, "first_field") > 0 Or InStr(fCode, "second_field") > 0
> Then
> fString = aField.Result
> aField.Delete
> fCode.Text = Replace(fString, vbCr, "")
> For i = 1 To fCode.Paragraphs.Count
> With fCode.Paragraphs(i)
> .LeftIndent = InchesToPoints(0.25)
> .FirstLineIndent = InchesToPoints(-0.25)
> End With
> Next i
> End If
> Next aField
>
> Unload oFrm
> Set oFrm = Nothing
> Set oVars = Nothing
> Set oRng = Nothing
> End Sub
> ---\ Code ---- |
|
| Back to top |
|
 |
Abel MacAdam External

Since: Mar 27, 2009 Posts: 8
|
Posted: Fri May 08, 2009 8:10 am Post subject: Re: After form execution: Strange characters in 2007 (II) [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
It seems I'm not entirely true on what I observed. The second result should
be displayed as:
--field------------
his is my first line.[?][?][?][?]This is my second line.[?][?][?][?]This is
a third line.
--end field-------
With [?] I mean a character that looks like a question mark in a square.
"Doug Robbins - Word MVP" wrote:
> Sorry, I probably should have said to use Replace([your string], Chr(10),
> "")
>
> --
> 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:D04BA9AD-6D67-473B-A12A-F030E36B6986@microsoft.com...
> > Hello,
> >
> > This is a problem that is slightly different from the one I posted
> > earlier.
> > As I had a follow up question in that post, and did not want to confuse
> > the
> > issue, I thought it wiser to make a new post for this related problem.
> >
> > I have text field in my form which allows multiple paragraphs. These
> > multiple paragraphs should appear as multiple paragraphs in the document.
> > But
> > instead of multiple paragraphs I get one line. It looks like:
> >
> > --form------------------
> > This is my first line.
> > <>
> > <>This is my second line.
> > <>
> > <>This is a third line
> > --end form-------------
> >
> > It appears as
> > --document------------
> > his is my first line.<><><><>This is my second line.<><><><>This is a
> > third
> > line
> > --end document-------
> >
> > I thought I had it covered by adding a "Replace(fString, vbCr, "")" in my
> > code. It did not work out as expected (the first field comes out as
> > described
> > above, the second field comes out as expected, but then as plain-old-text,
> > not as field with contents).
> >
> > Does anyone know what I can do?
> >
> > Abel
> >
> > The code I use to get the splendid but unexpected result described above:
> > --Code----
> > Sub CallUF()
> > Dim oFrm As myForm
> > Dim oVars As Word.Variables
> > Dim pString As String
> > Dim oRng As Range
> > Dim i As Long
> > Set oVars = ActiveDocument.Variables
> > Set oFrm = New myForm
> > With oFrm
> > .Show
> > If .boolProceed Then
> > oVars("contractnumber") = .contractnumber.Text
> > oVars("customer") = .customer.Text
> > oVars("cust_service") = .cust_service.Text
> > oVars("webserver_number") = .webserver_number.Text
> > oVars("webserver_hostname") = .webserver_hostname.Text
> > oVars("databaseserver_number") = .databaseserver_number.Text
> > oVars("databaseserver_hostname") = .databaseserver_hostname.Text
> > UpdateFormVelden
> > End If
> > End With
> >
> > Dim aField As Field
> > Dim fCode As Range
> > Dim fString As String
> >
> > For Each aField In ActiveDocument.Fields
> > Set fCode = aField.Code
> > If InStr(fCode, "first_field") > 0 Or InStr(fCode, "second_field") > 0
> > Then
> > fString = aField.Result
> > aField.Delete
> > fCode.Text = Replace(fString, vbCr, "")
> > For i = 1 To fCode.Paragraphs.Count
> > With fCode.Paragraphs(i)
> > .LeftIndent = InchesToPoints(0.25)
> > .FirstLineIndent = InchesToPoints(-0.25)
> > End With
> > Next i
> > End If
> > Next aField
> >
> > Unload oFrm
> > Set oFrm = Nothing
> > Set oVars = Nothing
> > Set oRng = Nothing
> > End Sub
> > ---\ Code ----
>
> |
|
| Back to top |
|
 |
Abel MacAdam External

Since: Mar 27, 2009 Posts: 8
|
Posted: Fri May 08, 2009 8:10 am Post subject: Re: After form execution: Strange characters in 2007 (II) [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
I found the cause for the <> and the [?] (wrong variable name). Thanks
"Abel MacAdam" wrote:
> It seems I'm not entirely true on what I observed. The second result should
> be displayed as:
> --field------------
> his is my first line.[?][?][?][?]This is my second line.[?][?][?][?]This is
> a third line.
> --end field-------
>
> With [?] I mean a character that looks like a question mark in a square.
>
> "Doug Robbins - Word MVP" wrote:
>
> > Sorry, I probably should have said to use Replace([your string], Chr(10),
> > "")
> >
> > --
> > 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:D04BA9AD-6D67-473B-A12A-F030E36B6986@microsoft.com...
> > > Hello,
> > >
> > > This is a problem that is slightly different from the one I posted
> > > earlier.
> > > As I had a follow up question in that post, and did not want to confuse
> > > the
> > > issue, I thought it wiser to make a new post for this related problem.
> > >
> > > I have text field in my form which allows multiple paragraphs. These
> > > multiple paragraphs should appear as multiple paragraphs in the document.
> > > But
> > > instead of multiple paragraphs I get one line. It looks like:
> > >
> > > --form------------------
> > > This is my first line.
> > > <>
> > > <>This is my second line.
> > > <>
> > > <>This is a third line
> > > --end form-------------
> > >
> > > It appears as
> > > --document------------
> > > his is my first line.<><><><>This is my second line.<><><><>This is a
> > > third
> > > line
> > > --end document-------
> > >
> > > I thought I had it covered by adding a "Replace(fString, vbCr, "")" in my
> > > code. It did not work out as expected (the first field comes out as
> > > described
> > > above, the second field comes out as expected, but then as plain-old-text,
> > > not as field with contents).
> > >
> > > Does anyone know what I can do?
> > >
> > > Abel
> > >
> > > The code I use to get the splendid but unexpected result described above:
> > > --Code----
> > > Sub CallUF()
> > > Dim oFrm As myForm
> > > Dim oVars As Word.Variables
> > > Dim pString As String
> > > Dim oRng As Range
> > > Dim i As Long
> > > Set oVars = ActiveDocument.Variables
> > > Set oFrm = New myForm
> > > With oFrm
> > > .Show
> > > If .boolProceed Then
> > > oVars("contractnumber") = .contractnumber.Text
> > > oVars("customer") = .customer.Text
> > > oVars("cust_service") = .cust_service.Text
> > > oVars("webserver_number") = .webserver_number.Text
> > > oVars("webserver_hostname") = .webserver_hostname.Text
> > > oVars("databaseserver_number") = .databaseserver_number.Text
> > > oVars("databaseserver_hostname") = .databaseserver_hostname.Text
> > > UpdateFormVelden
> > > End If
> > > End With
> > >
> > > Dim aField As Field
> > > Dim fCode As Range
> > > Dim fString As String
> > >
> > > For Each aField In ActiveDocument.Fields
> > > Set fCode = aField.Code
> > > If InStr(fCode, "first_field") > 0 Or InStr(fCode, "second_field") > 0
> > > Then
> > > fString = aField.Result
> > > aField.Delete
> > > fCode.Text = Replace(fString, vbCr, "")
> > > For i = 1 To fCode.Paragraphs.Count
> > > With fCode.Paragraphs(i)
> > > .LeftIndent = InchesToPoints(0.25)
> > > .FirstLineIndent = InchesToPoints(-0.25)
> > > End With
> > > Next i
> > > End If
> > > Next aField
> > >
> > > Unload oFrm
> > > Set oFrm = Nothing
> > > Set oVars = Nothing
> > > Set oRng = Nothing
> > > End Sub
> > > ---\ Code ----
> >
> > |
|
| 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
|
| |
|
|