Woody and I also have a macro to export all macros at once.
Public Const AppName$ = "Enveloper" Public Const AppVer$ = "97"
This way, I no longer have to use an InitApp procedure in every macro just to set these variables on a per module basis.
The venerable Swap$() is a good example.
The converter automatically does that for you in MAIN, but you may not always access a module via MAIN (Enveloper uses multiple entry points per macro).
Since I had a InitGlobals() procedure for all significant macros, I can move those initialization statements there from MAIN.
Dim myarray(5) Sub MAIN ... ReDim myarray(10) ... End Sub
That is now converted to:
Dim myarray() Sub MAIN ReDim myarray(5) ... ReDim myarray(10) ... End Sub
Dim foo$
Then
foo = "Ha"
and
foo$ = "Ha"
are equivalent.
vbNewLine instead of Chr$(13)
vbYesNo (for MsgBox) instead of.....4?
ActiveDocument.Protect wdNoProtection
even though that's how you check the protection status. That is inconsistent, in my view.
MsgBox WordBasic.[GetBookmark$]("Date")
But the following VBA is not allowed because the document is protected:
MsgBox ActiveDocument.Bookmarks("Date").Range.Text
To do it via VBA, you have to first unprotect the form, run the above command, then protect the form again. What a pain.
To do the update manually, you'll have to resort to the WordBasic command:
WordBasic.SetFormResult "myCalcField"
to update the "myCalcField". There is NO Word/VBA equivalent.
On Error GoTo -1 : On Error GoTo YourLabel
1. DocA.doc has a toolbar named "Foo"
2. DocB.doc has a toolbar named "Bar"
From DocB.doc, try to change "Bar" to "Foo", you'll get the error message that "Foo" already exists and Word won't let me change it.
This is a BUG. Since "Foo" is not accessible to DocB.doc, it should not be an error. If you close DocA.doc, then you can rename "Bar" to "Foo"
' WB: prompt, title, buttons
' VBA: prompt, buttons, title
szFile = VBE.ActiveVBProject.VBComponents(1).Properties("Name")
In Word the "ThisDocument" VBComponent should always be at index 1. Note: VBComponent.Properties("Name") returns the pointer to the Name method. VBComponent.Properties("Name").Value returns the default return value of the method.
Declare Function foo Lib "MyLib" Alias "fooA"(\ myarg As Long) As Long
The macro converter fails, because it doesn't stick a space in from of the resulting line-continuation character. Woody and I have a macro that will fix this, but it's a pain.
Dim fdsf As FormatDefineStyleFont GetCurValues fdsf Dim ff As FormatFont ff.Font = fdsf.Font ff.Points = fdsf.Points .... FormatFont ff
Not until I REMOVED the menu entries altogether and added new ones from scratch did the changes hold.
Copyright © 1997 Vincent Chen.
*This creates an error if ActiveDocument.ThisDocument.Hello and AttachedTemplate.ThisDocument.Hello both exist. This means that you cannot have Public Subs in the ThisDocument object of a template and be able to use Application.Run, since every time you create a document based on that template, those subs will be duplicated in the document. Then any attempt to run those Subs via Applica-tion.Run will generate an error. You can, however, call Application.Run "AttachedTemplate.ThisDocument.Hello" to reach the one in the underlying template.
This file is also available for download as a zipped Word95 document.
| Migrating to Office97 |