R
rija
Hi Folks,
What I mean is that I had created a document with a macro program,
that allow me to personalize my document using a form and selecting
datas from tables using Documents.Open(FileName:="c:\Table.doc") then
when I display the data in the document, after each field, the
document insert a return chariot although I do not want such a mess.
So what's wrong with my program? and how can I get rid of it?
The program is display as following:
Dim texto(11) As String
Private Sub ComboBox1_Enter()
Dim sourcedoc As Document, i As Long, myitem As Range
Set sourcedoc = Documents.Open(FileName:="c:\worddocs\TestTable.doc")
For i = 0 To sourcedoc.Tables(1).Rows.Count
Set myitem = sourcedoc.Tables(1).Cell(i + 1, 1).Range
texto(i) = sourcedoc.Tables(1).Cell(i + 1, 2).Range
myitem.End = myitem.End - 1
ComboBox1.AddItem myitem.text
Next i
sourcedoc.Close SaveChanges:=wdDoNotSaveChanges
End Sub
Private Sub CommandButton1_Click()
Dim ComboBox As String
If TextBox1 <> "" Then
If Textbox2 <> "" Then
Textbox2 = " jusqu'au " + Textbox2
With ActiveDocument
.Bookmarks("Text2").Range _
.InsertBefore Textbox2
End With
End If
MsgBox (ComboBox1)
Select Case ComboBox1
Case "Accident"
ComboBox = texto(0)
Case "Airport"
ComboBox = texto(1)
Case "Cold and flue"
ComboBox = texto(2)
Case "Death"
ComboBox = texto(3)
Case "Visit"
ComboBox = texto(4)
Case "Family problem"
ComboBox = texto(5)
Case "Forgot"
ComboBox = texto(6)
Case "Malaria"
ComboBox = texto(7)
Case "Tiredeness"
ComboBox = texto(8)
Case "Transportation"
ComboBox = texto(9)
Case "Trip"
ComboBox = texto(10)
End Select
With ActiveDocument
.Bookmarks("Text0").Range _
.InsertAfter Trim(ComboBox)
End With
With ActiveDocument
.Bookmarks("Text1").Range _
.InsertBefore TextBox1
End With
UserForm1.Hide
End If
End Sub
Cheers
Rija
What I mean is that I had created a document with a macro program,
that allow me to personalize my document using a form and selecting
datas from tables using Documents.Open(FileName:="c:\Table.doc") then
when I display the data in the document, after each field, the
document insert a return chariot although I do not want such a mess.
So what's wrong with my program? and how can I get rid of it?
The program is display as following:
Dim texto(11) As String
Private Sub ComboBox1_Enter()
Dim sourcedoc As Document, i As Long, myitem As Range
Set sourcedoc = Documents.Open(FileName:="c:\worddocs\TestTable.doc")
For i = 0 To sourcedoc.Tables(1).Rows.Count
Set myitem = sourcedoc.Tables(1).Cell(i + 1, 1).Range
texto(i) = sourcedoc.Tables(1).Cell(i + 1, 2).Range
myitem.End = myitem.End - 1
ComboBox1.AddItem myitem.text
Next i
sourcedoc.Close SaveChanges:=wdDoNotSaveChanges
End Sub
Private Sub CommandButton1_Click()
Dim ComboBox As String
If TextBox1 <> "" Then
If Textbox2 <> "" Then
Textbox2 = " jusqu'au " + Textbox2
With ActiveDocument
.Bookmarks("Text2").Range _
.InsertBefore Textbox2
End With
End If
MsgBox (ComboBox1)
Select Case ComboBox1
Case "Accident"
ComboBox = texto(0)
Case "Airport"
ComboBox = texto(1)
Case "Cold and flue"
ComboBox = texto(2)
Case "Death"
ComboBox = texto(3)
Case "Visit"
ComboBox = texto(4)
Case "Family problem"
ComboBox = texto(5)
Case "Forgot"
ComboBox = texto(6)
Case "Malaria"
ComboBox = texto(7)
Case "Tiredeness"
ComboBox = texto(8)
Case "Transportation"
ComboBox = texto(9)
Case "Trip"
ComboBox = texto(10)
End Select
With ActiveDocument
.Bookmarks("Text0").Range _
.InsertAfter Trim(ComboBox)
End With
With ActiveDocument
.Bookmarks("Text1").Range _
.InsertBefore TextBox1
End With
UserForm1.Hide
End If
End Sub
Cheers
Rija