Share via

Word Basic Related Questions

Anonymous
2015-11-26T16:12:19+00:00

I have been drafted to resurrect an old Word application (almost 15 years old, updated over time) that has coded Macros that still use considerable Word Basic syntax, the last time the application was used on the company network (4 years ago) the environment was Windows 7, Office 2010, and SQL Server.  The current company environment is Windows 7, Office 2013, and SQL Server (mix of 32-bit and 64-bit components, OS is 64-bit, Office 2013 is 32-bit).

I am able to get the application running on a stand alone laptop that has Windows 7, Office 2010, and SQL Server (all 64-bit). 

However when I installed all the components on a company laptop (with all the security features that entails) with Windows 7, Office 2013 (32-bit), and SQL Server I am having issues with the Word Basic code (e.g. Error 509).  The application uses custom Registry settings (I did update them also in WPW6432node to compensate for the 32-bit component), I am aware also of PtrSafe, the non Word Basic code seems to be working (I am connecting to the database too), the References settings are the same, the code does compile clean, my challenge appears to be with the Word Basic syntax (e.g. ).

I am having another laptop built with Windows 7, Office 2010, and SQL Server, this would mimic the environment used 4 years ago, I am not sure if this will solve the issue but I will try.

Is there something about Office 2013 Word, and old Word Basic code, that I may not realize (e.g. no longer compatible, no longer able to run as such)?

Is there something in general I need to be aware with my product/version selection?

Any recommendations/suggestions would be appreciated.

Here are some sample statements having issues (this Macro is clearing and populating a Word table in a document called Gumby.doc):

a.  The following code actually does open the document, and the table is there (with 20 rows), but when it hits the Word Basic code an Error 509 is triggered (Error 509 occurred:  The TableSelectRow command is not available because some or all of the current selection is not in a table).

gumbyFile = getRegistryValue(MACRO_FOLDER) & "\GUMBY.DOC"

Documents.Open fileName:=gumbyFile

WordBasic.EditSelectAll

WordBasic.WW6_EditClear

b.  The following loop fails right off the bat when trying to execute the Word Basic commands

While i <= numberOfFoundFiles

        '***********************************************************************'

        '* Only process non tmp files

        '***********************************************************************'

        If Right(WordBasic.FoundFileName$, 4) <> ".tmp" Then

            Documents.Open fileName:=WordBasic.FoundFileName$

            Set dlg = WordBasic.DialogRecord.FileSummaryInfo(False)

            WordBasic.CurValues.FileSummaryInfo dlg

            CreateDate$ = dlg.CreateDate

            WordBasic.NormalViewHeaderArea Type:=1, FirstPage:=0, OddAndEvenPages:=0, HeaderDistance:="0.5", FooterDistance:="0.5"

            WordBasic.LineDown 2

            WordBasic.TableSelectRow

            WordBasic.EditCopy

            ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges

            WordBasic.EditPaste

            WordBasic.LineUp 1

            WordBasic.TableInsertCells ShiftCells:=0

            WordBasic.Insert Str(i) + "."

            WordBasic.TableColumnWidth ColumnWidth:="0.6", SpaceBetweenCols:="0", RulerStyle:="0"

            WordBasic.NextCell

            fileName = WordBasic.Selection$

            WordBasic.NextCell

            author$ = WordBasic.Selection$

            WordBasic.NextCell

            Status$ = WordBasic.Selection$

            filelen_ = Len(fileName)

            Para_$ = Mid(fileName, filelen_ - 21, 3)

            SubP$ = Mid(fileName, filelen_ - 15, 3)

            SubSubP$ = Mid(fileName, filelen_ - 9, 2)

            Rev$ = Mid(fileName, filelen_ - 3, 3)

            WordBasic.LineDown 1

            '*****************************************************

            '*  Done to Prevent memory errors resulting from edit

            '*  buffer running out of space.(Too many edit-pastes)

            '*****************************************************

            If LoopCtr >= 20 Then

                LoopCtr = 0

                ActiveDocument.Save

                ActiveDocument.Close

                Documents.Open fileName:=gumbyFile

                WordBasic.endofdocument

            Else

                LoopCtr = LoopCtr + 1

            End If

        End If

        i = i + 1

Wend

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2015-11-30T20:47:54+00:00

    near the top of the code these 2 lines

    WordBasic.EditSelectAll

    WordBasic.WW6_EditClear

    clear the content of the document

    and then the error 509  is raised when the code is trying to access a table in the document

    WordBasic.TableSelectRow

    it's hard to tell more without seeing the gumby document

    Was this answer helpful?

    0 comments No comments