|
25 Years of Programming
An open source source for C, C++, OWL, BASIC, MDB, XLS, DOT, and more... |
Home Projects Up Sitemap Search Blog Forum+Chat About Us Privacy Terms of Use Feedback FAQ Images Services Payments Humor Music |
Prepare to edit a C or C++ file in Microsoft Word 2003The source code files and many example projects that were supplied with Borland ObjectWindows Library all used a C++ formatting style different from what I normally use. I found that it was much easier to understand the code at a glance if I reformatted it to my liking. Since there were hundreds of files to reformat, I eventually created an automated procedure to do the job in Microsoft Word. The reformatting macros are in my CPROGRAM.DOT Word template. The macro listed below should be added to your Normal.dot template. When you first open the C or C++ file that you want to reformat, it will have the Normal.dot template attached to it by default. When you run this macro, it attaches the CPROGRAM.DOT template to the document, instead. This makes available the reformatting macros, and a toolbar that can be useful. When you're done, save the reformatted file as plain text only. There is an earlier version of this macro for Word 6.0. |
Attribute VB_Name = "AttachCProgramDOT"
Public Sub MAIN()
Attribute MAIN.VB_Description = "Attaches CPROGRAM.DOT template to current document, making its C++ formatting macros available, and changing fonts."
Attribute MAIN.VB_ProcData.VB_Invoke_Func = "TemplateProject.AttachCProgramDOT.MAIN"
Rem 1-31-99, 1/15/04
Rem Copyright (C)1999-2005 Steven Whitney.
Rem Initially published by http://25yearsofprogramming.com.
Rem Published under GNU GPL (General Public License) Version 3, with ABSOLUTELY NO WARRANTY.
Rem Attaches CPROGRAM.DOT to active document in preparation for file EDITING.
Rem makes my CPP macros available and changes the font and tab stops.
Rem if you convert a document and save it, it remains based on cprogram.dot,
Rem which has different tab stops, and can hang up MSWord when it exits.
If WordBasic.MsgBox("To convert an ordinary document to 10cpi, just change the font to CourierNew 10. Converting it to CPP has some undesirable side effects. CONVERT to a .CPP program file?", "Are You Sure?", 33) <> -1 Then GoTo Bye
Rem Turn off everything related to autocorrect.
Rem This is important when you're about to edit an actual CPP file.
WordBasic.ToolsAutoCorrect SmartQuotes:=0, InitialCaps:=0, SentenceCaps:=0, Days:=0, ReplaceText:=0, Formatting:=0, Replace:="", With:=""
WordBasic.FileTemplates Store:=0, Template:="c:\msoffice\winword\template\cprogram.dot", LinkStyles:=1
Rem SET TABS TO 4 CHARS AT 12CPI = 1/3"
WordBasic.FormatTabs Position:="", DefTabs:="0.33" + Chr(34), Align:=0, Leader:=0
Rem DISPLAY THE PROGRAMMING TOOLS TOOLBAR
WordBasic.ViewToolbars Toolbar:="Programming Tools", Show:=1
If WordBasic.MsgBox("Turn AUTOCORRECT back ON?", "Configure", 36) = -1 Then
WordBasic.ToolsAutoCorrect SmartQuotes:=0, InitialCaps:=1, SentenceCaps:=1, Days:=1, ReplaceText:=1, Formatting:=0, Replace:="", With:=""
End If
Bye:
End Sub
|
|
|
|
|
Copyright ©2010 Steven Whitney. Last modified Thu 10/21/2010 02:08:02 -0700. |
||