PDA

View Full Version : Why do i make my result to display like that



thedark123
06-05-2006, 10:00 PM
here is my coding and the results displays in this way..

' Initialise all variables for extra feature
Dim tcount As Integer
Dim y As Integer
Dim testid()
Dim rcount()
tcount = ActiveDocument.Tables.Count
y = 0
ReDim testid(tcount)
ReDim rcount(tcount)

For j = 0 To tcount
ActiveDocument.Tables(j).Select
With Selection.Find
.ClearFormatting
.Text = "Test Case ID:"
.Format = True
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False

.Forward = True
Do While .Execute(Forward:=True, Format:=True) = True
With .Parent
testid(j) = ActiveDocument.Tables(j).Cell(1, 2).Range
rcount(j) = ActiveDocument.Tables(j).Rows.Count - 4
End With
Loop
End With
Next j

ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges

' Type results into table
Selection.TypeText MyName & vbTab & FileLen(MyName) _
& vbTab & FileDateTime(MyName) & vbTab & counter & vbLf & vbLf

' Type results from extra feature into table
For k = 0 To tcount
Selection.TypeText testid(k) & vbTab & rcount(k) & vbLf
Next k
counter = 0
tcounter = 0
Next i


http://i6.photobucket.com/albums/y226/thedark123/oldfile.gif


how to make the display in this manner?

http://i6.photobucket.com/albums/y226/thedark123/newpic.gif

fumei
06-05-2006, 10:41 PM
Please....be concise in your posts. However....

1. You declare y As Integer; you set y = 0. You never use y. Hmmmm. Maybe it is used somewhere else - if so...is it relevant here?

2. Is j declared anywhere? Are you using Option Explicit?

3. j = 0 ( For j = 0 To tcount) Excuse me, but would not ActiveDocument.Tables(0).Select return an error? It sure does for me!

4. It looks like you are putting stuff into a table, but your images show no cell borders. It is hard to see if the cell structure is correct.

5. Your code snippet ends with Next i...but there is no code for what i (assuming a For Next loop) is doing. There is no START visible of the For i = loop.

6. the code:Selection.TypeText MyName & vbTab & FileLen(MyName) _
& vbTab & FileDateTime(MyName) & vbTab & counter & vbLf & vbLf clearly makes two linefeeds. That is why there are spaces after your text. Why not make the cell contents explicit? Do not use Selection. This has been mentioned before. Do not use Selection. You can put text into a cell explicitly use the Range.Text of that cell.

7. Speaking of which,testid(j) = ActiveDocument.Tables(j).Cell(1, 2).Range .As textid is a Variant, this is actually picking up the Range of the cell. If you want this to be text, it would be better to declare testid As String, and use .Cell(1,2).Range.Text

8. I can not figure out whatrcount(j) = ActiveDocument.Tables(j).Rows.Count - 4 is doing.

9. Is "TC-COMMON-FM016-B00.01 2" in one cell? Is it in two cells? Hard to figure that out. But again, it may be easier to simply write .Cell(x,y).Range.Text as being whatever it is you want. Rather than using Selection.TypeText.

thedark123
06-05-2006, 11:10 PM
hmm but then u haven say how to remove the dot that u see after every sentence



testid(j) = ActiveDocument.Tables(j).Cell(1, 2).Range




rcount(j) = ActiveDocument.Tables(j).Rows.Count - 4


the above 2 coding dun affect the dot right?

what affect is this piece of coding?

Selection.TypeText testid(k) & vbTab & rcount(k) & vbLf

fumei
06-06-2006, 12:11 AM
Sorry, but that is meaningless to me.

The "dot" is there...because....?

Look. Answer the questions - is this in ONE cell? Yes - No.

Try using a style - the way Word is supposed to be used. If you would use a style for the cells, then the format - ALL OF IT - will be in the style. Then do as I suggest. Put your text into the cell range, and not use the Selection to type it in.

I am not sure how you are getting the "dot". It looks like a bullet. If it is, then you put it there. Word will not put a bullet in just randomly. If you don't like it, then don't put it there. Another reason to properly use Styles.


what affect is this piece of coding?

Selection.TypeText testid(k) & vbTab & rcount(k) & vbLf

All I can say to that is....huh? What are you talking about???? The "effect" is Word will type in the contents of the array testid (using item variable = k), followed by a Tab, followed by the contents of the array rcount (using item variable = k), followed by a line feed. Hmmmm. Just like it is written.

thedark123
06-06-2006, 12:24 AM
Yes it is all in one cell


Selection.TypeText testid(k) & vbTab & rcount(k) & vbLf will show this part

http://i6.photobucket.com/albums/y226/thedark123/example1.gif


the problwm is with this, the spacing and everything will be affected by the above coding.

fumei
06-06-2006, 12:40 AM
You are not listening. Try something different. Try using Styles.

SOMETHING is putting a bullet there.