I haven't studied VBSript, but in order to format the code you want, I found it and didn't find something appropriate, barely made one. Usage: Use the following code to load this macro with VC6, open any C, C code file, run the macro, the code will be formatted according to the system settings (spaces or Tab). Because it doesn't understand VBSript, it is not perfect, the problem is: 1: Must open the formatted file in the VC and other environments, can not automatically retrieve the formatted file according to the directory; 2: When "{", there is character Lost indentation in {};
Condition: The file must be written.
The value of the existence: The VC environment is the environment trusted, and it will never be compiled because it formats the code to code.
I hope some people don't worry, do it well. If there is a new version, please send me: yanggr@cbcyber.com
Sub formatbycode () DIM MyDocument for Each MyDocument in Application.Documents MyDocument.Active = true myDocument.selection.selectAll
DIM endline, currine endline = myDocument.selection.bottomline myDocument.selection.startofline currline = myDocument.selection.currentline
While (currline <= endline) myDocument.selection.selection = ltrim (myDocument.selection) currline = myDocument.selection.currentline Wend
myDocument.Selection.SelectAll myDocument.Selection.Unindent myDocument.Selection.Unindent myDocument.Selection.Unindent myDocument.Selection.Unindent myDocument.Selection.Unindent myDocument.Selection.Unindent myDocument.Selection.SmartFormat myDocument.Save myDocument.Close dsSaveChangesPrompt NextEnd Sub