Consulting

Results 1 to 19 of 19

Thread: i'm wondering - What's wrong ???

  1. #1
    VBAX Regular
    Joined
    Dec 2015
    Posts
    89
    Location

    i'm wondering - What's wrong ???

    I'm using the below macro:



    Sub hhh()
         
        Dim oSld As Slide
        Dim oShp As Shape
            
        On Error Resume Next
        
        Set oSld = ActiveWindow.View.Slide
            
        For Each oShp In oSld.Shapes
        
    '-------------------------- Table --------------------------
     
            If oShp.HasTable Then
            Call r2LTable(oShp.Table)
            End If
                End Sub
    Sub r2LTable(otbl As Table)
    Dim iRow As Integer
        Dim iCol As Integer
        Dim L As Long
        
        For iRow = 1 To otbl.Rows.Count
    For iCol = 1 To otbl.Columns.Count
    With otbl.Cell(iRow, iCol).Shape.TextFrame.TextRange
                       .Font.Name = "Arial"
            .Font.NameComplexScript = "Arial"
            .ParagraphFormat.TextDirection = ppDirectionRightToLeft
            .RtlRun
                
    If .ParagraphFormat.Alignment = ppAlignLeft Then
                   .ParagraphFormat.Alignment = ppAlignRight
                End If
                    
                         If CharType(.Characters(L)) = "English" Then
                                With .Characters(L)
                                     .LanguageID = msoLanguageIDEnglishUS
                                End With
                         ElseIf CharType(.Characters(L)) = "Space" Then
                                'If CharType(.Characters(L - 1)) = "English" And CharType(.Characters(L + 1)) = "English" Then
                                With .Characters(L)
                                     '.Font.Underline = -4119
                                     .LanguageID = msoLanguageIDEnglishUS
                                End With
                                'End If
                         End If
                Next L
    End With
    Next iCol
    Next iRow
    End Sub

    It didn't work until i comment this line:

    'If CharType(.Characters(L - 1)) = "English" And CharType(.Characters(L + 1)) = "English" Then

    !!!!!!!!

    any explanations ?






    Private Function CharType(Letter As String) As String
    Select Case AscW(Letter)
        
        Case 32
            CharType = "Space"
        Case 48 To 57 '0-9
            CharType = "English"
        Case 65 To 90 'A-Z
            CharType = "English"
        Case 97 To 122 'a-z
            CharType = "English"
            Case 174 '®
            CharType = "English"
        Case 8482 '™
            CharType = "English"
            Case 169 '©
            CharType = "English"
            Case 44 ',
            CharType = "English"
            Case 64 '@
            CharType = "English"
            End Select
    End Function
    Last edited by SamT; 01-26-2016 at 08:47 AM.

  2. #2
    VBAX Regular
    Joined
    Dec 2015
    Posts
    89
    Location
    Here you are the file for test.
    Attached Files Attached Files

  3. #3
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Please edit your post to add CODE Tags.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  4. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    Probably because when L =1 you are checking Characters(zero)
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  5. #5
    VBAX Regular
    Joined
    Dec 2015
    Posts
    89
    Location
    Quote Originally Posted by SamT View Post
    Please edit your post to add CODE Tags.
    Sorry SamT; How can i do that step ???

  6. #6
    VBAX Regular
    Joined
    Dec 2015
    Posts
    89
    Location
    Quote Originally Posted by John Wilson View Post
    Probably because when L =1 you are checking Characters(zero)
    I see that this code work properly on other tables not all; so if the case was like you thought can it be solved ??

  7. #7
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    The Editor # Icon will insert CODE Tags in the Editor TextBox, then you can paste your code between them. Or you can Select the code, then click the Icon and the editor will place the code between the Tags. Finally, you can type the Tags where needed.

    Use the "Edit Post" under your post to edit. If you don't see one there, let me know. I think it is on a time limit for Members.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  8. #8
    VBAX Regular
    Joined
    Dec 2015
    Posts
    89
    Location
    Quote Originally Posted by SamT View Post
    The Editor # Icon will insert CODE Tags in the Editor TextBox, then you can paste your code between them. Or you can Select the code, then click the Icon and the editor will place the code between the Tags. Finally, you can type the Tags where needed.

    Use the "Edit Post" under your post to edit. If you don't see one there, let me know. I think it is on a time limit for Members.
    Thanks SamT for your advise; Kindly note that i don't have "Edit Post" option.


  9. #9
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    Characters(zero) will always throw an error. You have On Error Resume Next set which will hide the error but may act on it in unpredictable ways.. Alter the code so (L-1) cannot equal zero of if it does that line is ignored
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  10. #10
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    Quote Originally Posted by baset View Post
    Thanks SamT for your advise; Kindly note that i don't have "Edit Post" option.

    There's some sort of time out window, after which you can't edit the post -- I think the moderators can (not sure)

    When you're within the window, you get another button that allows you to edit the post.

    I usually have to do that since my keyboard insists on making spelling mistakes which I don't catch until I post it (even with preview)


    Capture.JPG
    Last edited by Paul_Hossler; 01-26-2016 at 07:52 AM. Reason: And you can make a note the reason for the edit
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  11. #11
    VBAX Regular
    Joined
    Dec 2015
    Posts
    89
    Location
    Quote Originally Posted by Paul_Hossler View Post
    There's some sort of time out window, after which you can't edit the post -- I think the moderators can (not sure)

    When you're within the window, you get another button that allows you to edit the post.

    I usually have to do that since my keyboard insists on making spelling mistakes which I don't catch until I post it (even with preview)


    Capture.JPG
    Unfortunattely i don't have this command available:

    26-Jan-16 4-58-42 PM.jpg

  12. #12
    VBAX Regular
    Joined
    Dec 2015
    Posts
    89
    Location
    Quote Originally Posted by John Wilson View Post
    Characters(zero) will always throw an error. You have On Error Resume Next set which will hide the error but may act on it in unpredictable ways.. Alter the code so (L-1) cannot equal zero of if it does that line is ignored
    Dear John

    How can i do that step ???

  13. #13
    VBAX Regular
    Joined
    Dec 2015
    Posts
    89
    Location
    Quote Originally Posted by baset View Post
    Dear John

    How can i do that step ???
    this is what i did but not working:
    ElseIf CharType(.Characters(L)) = "Space" Or CharType(.Characters(L)) = "Dash" _
        Or CharType(.Characters(L)) = "Dot" Or CharType(.Characters(L)) = "Underscore" Then
        
                    'If CharType(.Characters(L - 1)) <> False Then
                    If CharType(.Characters(L - 1)) = "English" And CharType(.Characters(L + 1)) = "English" _
                    And CharType(.Characters(L - 1)) <> False Then
    
    
                        With .Characters(L)
                            '.Font.Underline = -4119
                             .LanguageID = msoLanguageIDEnglishUS
                        End With
                        End If
                    'End If

  14. #14
    VBAX Regular
    Joined
    Dec 2015
    Posts
    89
    Location
    Dear John

    This is another approach but also not working:

    For L = 1 To .Characters.Count            If CharType(.Characters(L)) = "English" Then
                    With .Characters(L)
                         .LanguageID = msoLanguageIDEnglishUS
                    End With
                End If
                
                If CharType(.Characters(L)) = "Space" Or CharType(.Characters(L)) = "Dash" _
        Or CharType(.Characters(L)) = "Dot" Or CharType(.Characters(L)) = "Underscore" Then
                    If CharType(.Characters(L - 1)) = "Null" Then
                    .Characters(L - 1) = L
                    ElseIf CharType(.Characters(L - 1)) = "English" And CharType(.Characters(L + 1)) = "English" Then
                        With .Characters(L)
                            '.Font.Underline = -4119
                             .LanguageID = msoLanguageIDEnglishUS
                        End With
                    End If
                End If
            Next L

  15. #15
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    If L-1 > O Then 
    If CharType(.Characters(L - 1)) = "Null" Then 
            .Characters(L - 1) = L 
        ElseIf CharType(.Characters(L - 1)) = "English" And CharType(.Characters(L + 1)) = "English" Then 
            With .Characters(L) 
                 '.Font.Underline = -4119
                .LanguageID = msoLanguageIDEnglishUS 
            End With 
        End If 
    End If
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  16. #16
    VBAX Regular
    Joined
    Dec 2015
    Posts
    89
    Location
    I noticed that the 1st part of the macro runs on all items inside the group while the 2nd one runs only on the first item and ignored the rest item; any explanations ???

    For ooo = 1 To ogrp.GroupItems.Count    Set oTxtRng = ogrp.GroupItems(ooo).TextFrame.TextRange
        With oTxtRng
        
        
        .Font.Name = "Arial"
            .Font.NameComplexScript = "Arial"
            .ParagraphFormat.TextDirection = ppDirectionRightToLeft
            .RtlRun
                If .ParagraphFormat.Alignment = ppAlignLeft Then
                   .ParagraphFormat.Alignment = ppAlignRight
                End If
    
    
    
    
             End With
            Next ooo

    For ooo = 1 To ogrp.GroupItems.Count    Set oTxtRng = ogrp.GroupItems(ooo).TextFrame.TextRange
        With oTxtRng
        
        
        For L = 1 To .Characters.Count
                If CharType(.Characters(L)) = "English" Then
                    With .Characters(L)
                         .LanguageID = msoLanguageIDEnglishUS
                    End With
                
                ElseIf CharType(.Characters(L)) = "Space" Or CharType(.Characters(L)) = "Dash" _
        Or CharType(.Characters(L)) = "Dot" Or CharType(.Characters(L)) = "Underscore" Then
                    If CharType(.Characters(L - 1)) = "English" And CharType(.Characters(L + 1)) = "English" Then
                        With .Characters(L)
                            '.Font.Underline = -4119
                             .LanguageID = msoLanguageIDEnglishUS
                        End With
                    End If
                End If
            Next L
    
    
    
    
             End With
            Next ooo

  17. #17
    VBAX Regular
    Joined
    Dec 2015
    Posts
    89
    Location
    Quote Originally Posted by SamT View Post
    If L-1 > O Then 
    If CharType(.Characters(L - 1)) = "Null" Then 
            .Characters(L - 1) = L 
        ElseIf CharType(.Characters(L - 1)) = "English" And CharType(.Characters(L + 1)) = "English" Then 
            With .Characters(L) 
                 '.Font.Underline = -4119
                .LanguageID = msoLanguageIDEnglishUS 
            End With 
        End If 
    End If

    Dear SamT

    Thanks for trying to help here; i used your code as shown below but still the same problem exist:

    For L = 1 To .Characters.Count            
    If CharType(.Characters(L)) = "English" Then
                    With .Characters(L)
                         .LanguageID = msoLanguageIDEnglishUS
                    End With
                
                ElseIf CharType(.Characters(L)) = "Space"  Then
                            If L - 1 > 0 Then
                            If CharType(.Characters(L - 1)) = "Null" Then
                                .Characters(L - 1) = L
                            ElseIf CharType(.Characters(L - 1)) = "English" And CharType(.Characters(L + 1)) = "English" Then
                                With .Characters(L)
                                     '.Font.Underline = -4119
                                    .LanguageID = msoLanguageIDEnglishUS
                                End With
                            End If
                        End If
                End If
            Next L

  18. #18
    VBAX Regular
    Joined
    Dec 2015
    Posts
    89
    Location
    Dear John


    You said "Probably because when L =1 you are checking Characters(zero)"


    Then said "Characters(zero) will always throw an error. You have On Error Resume Next set which will hide the error but may act on it in unpredictable ways.. Alter the code so (L-1) cannot equal zero of if it does that line is ignored"


    How can make sure that this is the reason of this fault; for example using a code like this:


    If CharType(.Characters(L + 1)) = "Null" Then
                               MsgBox ("Baset" & L)
              End If

  19. #19
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    If L > 1 Then
    If CharType(.Characters(L - 1)) = "Null" Then 
        MsgBox ("Baset" & L - 1) 
    End If 
    Else 'L - 1 = 0
    End If
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •