Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Nov 2003
    Posts
    61
    Thanks
    7
    Thanked 0 Times in 0 Posts

    WordBasic to VBA 6.3 (VBA 6.3)

    I have a bit of WordBasic code that I haven't a clue how to translate to VBA 6.3 for applications. Any tips on how I should proceed would be much appreciated. Here is is:



    Private Sub GetStyle(OrigName$)
    On Error Resume Next
    Rem ************************************************** **
    Rem * Sub GetStyle *
    Rem ************************************************** **
    Set Code$ Array
    For Sname 0
    Code$(0) = "[fchd]"

    Rem For Sname 7 - 11
    Code$(7) = "[fcs1]": Code$(8) = "[fcs2]": Code$(9) = "[fcs3]"
    Code$(10) = "[fcs4]": Code$(11) = "[fcs5]"

    Rem For Sname 12 - 19
    Code$(12) = "[fcxt]": Code$(13) = "[fcxf]": Code$(14) = "[fcbo]"

    Rem Sname equivelent
    Code$(1) = "[fch1]": Code$(2) = "[fch2]": Code$(3) = "[fch3]"
    Code$(4) = "[fcn1]": Code$(5) = "[fcn2]": Code$(6) = "[fcn3]"

    Rem Set Expected Style Names Array
    Rem Expected Section Head StyleName
    Sname$(0) = "_SectionHead"

    Rem Expected SubHead StyleNames
    Sname$(7) = "_SubHead1": Sname$(8) = "_SubHead2"
    Sname$(9) = "_SubHead3": Sname$(10) = "_SubHead4"
    Sname$(11) = "_SubHead5"

    Rem Expected Block Quote StyleNames
    Sname$(12) = "_1StQuoteTXT": Sname$(13) = "_2NdQuoteTXT"
    Sname$(14) = "_3RdQuoteTXT": Sname$(15) = "_4ThQuoteTXT"
    Sname$(16) = "_1StQuoteFN": Sname$(17) = "_2NdQuoteFN"
    Sname$(18) = "_3RdQuoteFN": Sname$(19) = "_4ThQuoteFN"
    Sname$(20) = "_1StLineQuoteFN": Sname$(21) = "_1stLineQuoteFN"
    Sname$(22) = "_1StLineQuoteFn1Num": Sname$(23) = "_1stLineQuoteFn1Num"
    Sname$(24) = "_1StLineQuoteFn2Num": Sname$(25) = "_1stLineQuoteFn2Num"
    Sname$(26) = "_1StLineQuoteFn3Num": Sname$(27) = "_1stLineQuoteFn3Num"

    Rem Turn off document protection, Save file, view to normal and start
    WordBasic.FileOpen Name:=OrigName$
    If WordBasic.DocumentProtection() <> 0 Then WordBasic.ToolsUnprotectDocument
    WordBasic.ToolsOptionsGeneral Pagination:=0
    WordBasic.FileSaveAs Name:=OrigName$, Format:=0
    If WordBasic.ViewNormal() = 0 Then WordBasic.ViewNormal
    SFR

    Rem Determine Number of Custom and Styles in use in document
    NumStyles = WordBasic.CountStyles(0, 0)

    Rem Test to see if this is a macro'd file, skip rest of sub if not
    TestForMacro
    WordBasic.StartOfDocument
    WordBasic.FileClose 2
    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: WordBasic to VBA 6.3 (VBA 6.3)

    The code calls two other procedures SFR and TestForMacro. Since we don't have the slightest idea what they do, it's impossible to guess what this code is for.

  3. #3
    Star Lounger
    Join Date
    Nov 2003
    Posts
    61
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Re: WordBasic to VBA 6.3 (VBA 6.3)

    Sorry, Hans. It is a part of a larger macro that takes Word files, splits them into a text and footnote files in .txt format. Then takes the styles and drops in codes identifying what style was used in each paragraph. Basically, it creates a markup file. This is part of the the style identifyer routine. It is really just the first couple of lines that are giving me debug problems.


    Rem Test to see if this is a macro'd file, skip rest of sub if not

    Private Sub TestForMacro()
    Dim loop_
    On Error Resume Next
    IsMacroFile = 0
    For loop_ = 1 To NumStyles
    If WordBasic.[StyleName$](loop_) = "_Journal font" Then IsMacroFile = 1
    Next loop_
    End Sub

    Private Sub SFR()
    On Error Resume Next
    WordBasic.StartOfDocument
    WordBasic.EditFindClearFormatting
    WordBasic.EditReplaceClearFormatting
    End Sub

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: WordBasic to VBA 6.3 (VBA 6.3)

    Try removing the two lines

    Set Code$ Array
    For Sname 0

    Instead, put these lines near the top of the module (before the Subs):

    Dim Code$(1 To 14)
    Dim Sname$(0 To 27)

  5. #5
    Star Lounger
    Join Date
    Nov 2003
    Posts
    61
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Re: WordBasic to VBA 6.3 (VBA 6.3)

    Thanks Hans! That seems to have gotten me to an error on some other code. I'm makin' progress! [img]/forums/images/smilies/smile.gif[/img]

Posting Permissions

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