Saintcools
07-08-2006, 12:34 AM
Hi All,
I have a small problem in running my VBA program.
This sub is used to select the folder which has Doc file
Private Sub ProcessFolder(fol As folder)
Dim subfolders As Folders
Dim folder As folder
Dim filecol As Files
Dim fil As File
Set subfolders = fol.subfolders
Set filecol = fol.Files
For Each fil In filecol
If UCase(Right(fil.Name, 3)) = "DOC" Then
Label1.Caption = " Adding Tags : " & fil.Path
'DoEvents
Call Savetext(fil.Path)
End If
Next
End Sub
This function is called inside the Processfolder sub
Function Savetext(FileName As String) As Boolean
Dim docfilename As String
Dim wrddoc As Object
On Error GoTo savetexterror
docfilename = FileName
'OPEN WORD DOCUMENT:
Set wrddoc = wrdApp.Documents.Open(docfilename)
'Call Functions
Call itags
'CLOSE WORD DOCUMENT
ActiveDocument.Close (wdSaveChanges)
wrddoc.Quit
Savetext = True
Savetextend:
Exit Function
savetexterror:
Savetext = False
Resume Savetextend
End Function
This sub is called inside the savetext function
private Sub itags()
Dim p As String
p = "<p align=""justify"">"
pc = "</p>"
For Each Paragraph In ActiveDocument.Paragraphs
Paragraph.Range.Select
If Paragraph.Style = "Normal" Then
Selection.Range.InsertBefore (p)
Selection.Range.MoveEnd unit:=wdCharacter, Count:=-1
Selection.Range.InsertAfter (pc)
End If
Next
End Sub
the problem is the itags sub keeps running infinitly inside the savetext function.all i need is that the sub ITAGS to one once and not infinite times.thanks in advance for your help.
I have a small problem in running my VBA program.
This sub is used to select the folder which has Doc file
Private Sub ProcessFolder(fol As folder)
Dim subfolders As Folders
Dim folder As folder
Dim filecol As Files
Dim fil As File
Set subfolders = fol.subfolders
Set filecol = fol.Files
For Each fil In filecol
If UCase(Right(fil.Name, 3)) = "DOC" Then
Label1.Caption = " Adding Tags : " & fil.Path
'DoEvents
Call Savetext(fil.Path)
End If
Next
End Sub
This function is called inside the Processfolder sub
Function Savetext(FileName As String) As Boolean
Dim docfilename As String
Dim wrddoc As Object
On Error GoTo savetexterror
docfilename = FileName
'OPEN WORD DOCUMENT:
Set wrddoc = wrdApp.Documents.Open(docfilename)
'Call Functions
Call itags
'CLOSE WORD DOCUMENT
ActiveDocument.Close (wdSaveChanges)
wrddoc.Quit
Savetext = True
Savetextend:
Exit Function
savetexterror:
Savetext = False
Resume Savetextend
End Function
This sub is called inside the savetext function
private Sub itags()
Dim p As String
p = "<p align=""justify"">"
pc = "</p>"
For Each Paragraph In ActiveDocument.Paragraphs
Paragraph.Range.Select
If Paragraph.Style = "Normal" Then
Selection.Range.InsertBefore (p)
Selection.Range.MoveEnd unit:=wdCharacter, Count:=-1
Selection.Range.InsertAfter (pc)
End If
Next
End Sub
the problem is the itags sub keeps running infinitly inside the savetext function.all i need is that the sub ITAGS to one once and not infinite times.thanks in advance for your help.