M
Malik Al-Amin
Hi all,
Here's my situation. I'm trying to copy the contents of one document into
another document. My problem is that I keep copying over the contents that
are already there. I don't want to copy over the paragraphs that are already
there, instead I want to add a new paragraph. This is the code I have so
far.
Dim TraceTree As Document
Dim UseCase As Document
Dim CaseTraceMerge As Document
Dim para As Paragraph
Dim strParaToFind As String
Dim pTraceToCopy As String
Dim sMyPara As String
' open the titles document in the background
Set TraceTree = Application.Documents.Open(FileName:="C:\TraceTree.doc",
Visible:=False)
' open the info doc in the background
Set UseCase = Application.Documents.Open(FileName:="C:\UseCase.doc",
Visible:=False)
Documents.Add.SaveAs FileName:="C:\Documents and
Settings\Malik\Desktop\fastsave.doc"
Set CaseTraceMerge = Documents("fastsave.doc")
iparacount = UseCase.Paragraphs.Count
For j = 1 To iparacount
sMyPara = UseCase.Paragraphs(j).Range.Text
For Each para In TraceTree.Paragraphs
If para.Range.Text <> sMyPara Then
pTraceToCopy = para.Range.Text
With CaseTraceMerge
.Range.Text = ptracecopy
.Range.ParagraphFormat.Alignment = wdAlignParagraphRight
.Range.InsertParagraphAfter
.Range.Collapse Direction:=wdCollapseEnd
End With
End If
Next
Next
I'm trying to open up a use case document and beginning with the first title
i want to open up the trace tree and find the matching title. Once found, I
want to copy the title and description (from the tracetree.doc) to a third
document. Then I want to loop to the next paragraph in the UseCase.doc and
repeat the process.
This is my first time trying to do any type of word programming so any
advice would be greatly appreciated.
Thanks
Here's my situation. I'm trying to copy the contents of one document into
another document. My problem is that I keep copying over the contents that
are already there. I don't want to copy over the paragraphs that are already
there, instead I want to add a new paragraph. This is the code I have so
far.
Dim TraceTree As Document
Dim UseCase As Document
Dim CaseTraceMerge As Document
Dim para As Paragraph
Dim strParaToFind As String
Dim pTraceToCopy As String
Dim sMyPara As String
' open the titles document in the background
Set TraceTree = Application.Documents.Open(FileName:="C:\TraceTree.doc",
Visible:=False)
' open the info doc in the background
Set UseCase = Application.Documents.Open(FileName:="C:\UseCase.doc",
Visible:=False)
Documents.Add.SaveAs FileName:="C:\Documents and
Settings\Malik\Desktop\fastsave.doc"
Set CaseTraceMerge = Documents("fastsave.doc")
iparacount = UseCase.Paragraphs.Count
For j = 1 To iparacount
sMyPara = UseCase.Paragraphs(j).Range.Text
For Each para In TraceTree.Paragraphs
If para.Range.Text <> sMyPara Then
pTraceToCopy = para.Range.Text
With CaseTraceMerge
.Range.Text = ptracecopy
.Range.ParagraphFormat.Alignment = wdAlignParagraphRight
.Range.InsertParagraphAfter
.Range.Collapse Direction:=wdCollapseEnd
End With
End If
Next
Next
I'm trying to open up a use case document and beginning with the first title
i want to open up the trace tree and find the matching title. Once found, I
want to copy the title and description (from the tracetree.doc) to a third
document. Then I want to loop to the next paragraph in the UseCase.doc and
repeat the process.
This is my first time trying to do any type of word programming so any
advice would be greatly appreciated.
Thanks