View Single Post
 
Old 04-04-2022, 03:12 AM
Bikram Bikram is offline Windows 10 Office 2007
Advanced Beginner
 
Join Date: Jul 2021
Location: Nepal
Posts: 97
Bikram is on a distinguished road
Default Returning Boolean

Greetings, I am trying to return boolean from a function but it is not returning its value. I know it is very simple but I have not been able why it is not returning value. Can anyone pointout what am i missing??
Code:
Sub autt()
Dim bln As Boolean, doc as document, i as integer,ii as integer
Set doc = ActiveDocument


    For i = 1 to Activedocument.range.paragraphs.count
    Set Para = doc.Paragraphs(i)
        If Selection.Information(wdWithInTable) = False Then
           bln = False
            Para.Range.Select
            
            

            bln = strr(bln)
            
            If bln = True Then                        'Here the boolean will be still be false even after assigning it to True in function
            If Not Left(Para.Range.Style, 1) = "1" Then
            If Para.Range.words(1) = Chr(9) Or Para.Range.words(2) = Chr(9) And bln = True Then
                Para.Range.Style = "tt"
            ElseIf Para.LeftIndent = 0 And Para.FirstLineIndent = 0 Then
                   Para.Range.Style = "t"
            End If
            If Para.Range.words(3) = Chr(9) Then
                    Para.Range.Style = "tt"
            End If
            End If
            End If
           
        Else
            ii = Selection.Tables(1).Range.Paragraphs.Count
            i = iparanum + ii
        End If
    Next

End Sub

Function strr(bln As Boolean) As Boolean
Dim x As Integer, rngg As String, y As Integer
rngg = Selection.Range.Text
x = Len(rngg): y = InStr(1, rngg, ":")
    If x - y < 3 And x - y >= 1 Then
        If Selection.Range.Text Like "*." & vbTab & "*" Then
            With Selection
                If .Paragraphs(1).Next.Range.Characters(1).Text = Chr(9) Then
                    .Paragraphs(1).Next.Range.Characters(1).Delete
                    .Range.Style = "tt"
                    .Range.Bold = True
                End If
            .Range.Characters(x).Delete
            .Range.Style = "tt"
            .Range.Bold = True
            bln = True                              'Here I have Set it to true the value in the main procedure is not turning to true
            End With
        End If
    End If
End Function
Reply With Quote