hello
we have an excel sheet that contain a macro who create a word document
every time we running it it fill all line with "all tests" even if the line 7 is empty.
not sure why.
plus the word doc created put text sometime in 2 lines instead of 1
here the code :
Thanks
we have an excel sheet that contain a macro who create a word document
every time we running it it fill all line with "all tests" even if the line 7 is empty.
not sure why.
plus the word doc created put text sometime in 2 lines instead of 1
here the code :
VBA Code:
Sub Main()
StartForm.Show
Dim Name As String
Dim OwordDocument As WordDocument
Dim OoutlookEvents As OutlookEvents
Dim Item As String
Dim Items() As String
Dim element As Variant
Sheet1.Activate
Dim LastCol As Integer
With ActiveSheet
LastCol = .Cells(2, .Columns.Count).End(xlToLeft).Column
End With
If ActiveSheet.Cells(StartForm.LineTextBox, 1).Text <> "" Then
Name = ActiveSheet.Cells(StartForm.LineTextBox, 1).Text
Set OwordDocument = New WordDocument
Set OoutlookEvents = New OutlookEvents
OwordDocument.InsertTitle (Name)
For i = 2 To LastCol
If ActiveSheet.Cells(StartForm.LineTextBox, i).Text <> "" And i <> 30 Then
Item = ActiveSheet.Cells(3, i).Text + " " + _
ActiveSheet.Cells(2, i).Text + " " + ActiveSheet.Cells(4, i).Text + " " + _
ActiveSheet.Cells(StartForm.LineTextBox, i).Text + ActiveSheet.Cells(5, i).Text + " " + _
ActiveSheet.Cells(6, i).Text + ActiveSheet.Cells(7, i).Text + _
" ,all tests"
OwordDocument.InsertItem (Item)
OoutlookEvents.SetEvent (Item)
End If
Next
If ActiveSheet.Cells(StartForm.LineTextBox, 30).Text <> "" Then
Items = Split(ActiveSheet.Cells(StartForm.LineTextBox, 30).Text, Chr(10))
OwordDocument.InsertRetests
For Each element In Items
OwordDocument.InsertItem (element)
OoutlookEvents.SetEvent ("Retest: " + element)
Next element
End If
End If
End Sub
Thanks