一、还是求WORD批量处理宏要求:将一个文件夹里的所有WORD文件(
我觉得这个可能很难。
如果我们让宏打开一个一个的文件执行设置字号操作,其实还是要让Word打开这些文件,速度还是很慢。 如果我们了解Word文档的内部结构,或许可以完全通过代码在后台实现,无须使用Word将它们一个个打开。
我不是太懂编程,不知有人懂吗? 或许我可以推荐你使用OfficeTab这款让Word、Excel、PowerPoint支持标签的插件(下载地址: 安装OfficeTab后,进入有多个DOC文档的文件夹,全选所有文件,按下回车键,Word就会打开所有文件并在同一个窗口中显示多个标签,执行宏代码,这样或许感觉舒服点。 不过我试了下打开40个DOC文件,确实有些慢,然后直接点Word右上角的关闭按钮,可能太多了,好像Word死掉了,后来终止进程才解决。
可能与系统配置不太好有关。呵呵!。
二、求个WORD批量处理宏要求:将一个文件夹里的所有WORD文件(当
这个其实非常简单,编几行代码便可瞬间完成,根本不用一个文件一个文件地来,全部批量自动化操作并保存关闭。
以Word2003为例。Word2007类似。
首先你可以用Word打开所有的DOC文档,然后菜单“工具---宏”,输入宏名:全部文档小五号,在“宏的位置”选择“Norma t(共用模板),再点“创建”,把以下代码复制粘贴到里面就可以了。 不论你是打开20还是50个文档,可以说是瞬间完成。
本方法是通过一个循环遍历所有打开的文档进行操作。 将变量doc定义为一个文档类型document,而Documents代表所有打开的文档,然后通过For Each循环遍历所有打开的文档,全选每一个文档并将字体设为9号字(即小五号)。
为了以后方便使用,你可以选择菜单“工具---自定义”,点“命令”选项卡,在左边的“类别”中找到“宏”,将右边的这个宏命令拖放到工具栏,以后点一下工具栏这个按钮就可以了,还可以点击这个窗口下边的“键盘”按钮,找的方法同上,给这个宏命令设定一个快捷方式。 以后想用时绝对超级方便快捷。
是否保存或既保存并关闭由你自己决定(修改代码即可),如果某个文档是新建的文档且从未保存过文件名,则弹出“另存为”对话框,如果全部是打开的文档,则自动保存并全部关闭。 Sub 全部文档小五号() On Error Resume Next Dim doc As Document For Each doc In Documents With doc 。
Activate 。Application。
Selection。WholeStory '全选 。
Application。Selection。
Font。Size = 9 '字体大小设为9号(即小五号) 。
Save '保存文档 。Close '关闭文档 End With Next doc End Sub 。
三、word的宏编码问题要求:将一个文件夹里的所有WORD文件(当然 爱
丑丑,你好!你需要的代码如下,打开word,执行复制以下宏代码(首尾Sub Macro1(),End Sub是重复的,不用复制),按快捷键Alt+F11,切换到Visual Basic 编辑器,粘贴代码即可! Sub Macro1() Application。
DisplayStatusBar = True Application。ShowWindowsInTaskbar = True Application。
ShowStartupDialog = True With ActiveWindow 。 DisplayHorizontalScrollBar = True 。
DisplayVerticalScrollBar = True 。DisplayLeftScrollBar = False 。
StyleAreaWidth = CentimetersToPoints(0) 。DisplayVerticalRuler = True 。
DisplayRightRuler = False 。 DisplayScreenTips = True With 。
View 。ShowAnimation = True 。
Draft = False 。 WrapToWindow = False 。
ShowPicturePlaceHolders = False 。ShowFieldCodes = False 。
ShowBookmarks = False 。 FieldShading = wdFieldShadingWhenSelected 。
ShowTabs = False 。ShowSpaces = False 。
ShowParagraphs = True 。 ShowHyphens = False 。
ShowHiddenText = False 。ShowAll = True 。
ShowDrawings = True 。 ShowObjectAnchors = False 。
ShowTextBoundaries = False 。ShowHighlight = True 。
ShowOptionalBreaks = False 。 DisplayPageBoundaries = True 。
DisplaySmartTags = True End With End With With Options 。 Pagination = True 。
WPHelp = False 。WPDocNavKeys = False 。
ShortMenuNames = False 。RTFInClipboard = True 。
BlueScreen = False 。EnableSound = False 。
ConfirmConversions = False 。UpdateLinksAtOpen = True 。
SendMailAttach = True 。MeasurementUnit = wdMillimeters 。
AllowPixelUnits = False 。UseCharacterUnit = True 。
AllowReadingMode = True 。AnimateScreenMovements = True 。
VirusProtection = False 。ApplyFarEastFontsToAscii = False 。
InterpretHighAnsi = wdAutoDetectHighAnsiFarEast 。BackgroundOpen = False 。
AutoCreateNewDrawings = True End With Application。 DisplayRecentFiles = True RecentFiles。
Maximum = 4 With ActiveDocument。Styles(wdStyleNormal)。
Font If 。NameFarEast = 。
NameAscii Then 。NameAscii = "" End If 。
NameFarEast = "" End With With ActiveDocument。 PageSetup 。
LineNumbering。Active = False 。
Orientation = wdOrientPortrait 。TopMargin = MillimetersToPoints(25。
4) 。BottomMargin = MillimetersToPoints(25。
4) 。LeftMargin = MillimetersToPoints(20) 。
RightMargin = MillimetersToPoints(20) 。 Gutter = MillimetersToPoints(10) 。
HeaderDistance = MillimetersToPoints(17) 。FooterDistance = MillimetersToPoints(20) 。
PageWidth = MillimetersToPoints(210) 。PageHeight = MillimetersToPoints(297) 。
FirstPageTray = wdPrinterDefaultBin 。 OtherPagesTray = wdPrinterDefaultBin 。
SectionStart = wdSectionNewPage 。OddAndEvenPagesHeaderFooter = False 。
DifferentFirstPageHeaderFooter = False 。VerticalAlignment = wdAlignVerticalTop 。
SuppressEndnotes = False 。 MirrorMargins = False 。
TwoPagesOnOne = False 。BookFoldPrinting = False 。
BookFoldRevPrinting = False 。 BookFoldPrintingSheets = 1 。
GutterPos = wdGutterPosLeft 。LayoutMode = wdLayoutModeLineGrid End With With Selection。
ParagraphFormat 。LeftIndent = MillimetersToPoints(0) 。
RightIndent = MillimetersToPoints(0) 。SpaceBefore = 0 。
SpaceBeforeAuto = False 。SpaceAfter = 0 。
SpaceAfterAuto = False 。LineSpacingRule = wdLineSpaceExactly 。
LineSpacing = 20 。Alignment = wdAlignParagraphJustify 。
WidowControl = False 。KeepWithNext = False 。
KeepTogether = False 。PageBreakBefore = False 。
NoLineNumber = False 。Hyphenation = True 。
FirstLineIndent = MillimetersToPoints(0) 。OutlineLevel = wdOutlineLevelBodyText 。
CharacterUnitLeftIndent = 0 。 CharacterUnitRightIndent = 0 。
CharacterUnitFirstLineIndent = 0 。LineUnitBefore = 0 。
LineUnitAfter = 0 。 AutoAdjustRightIndent = True 。
DisableLineHeightGrid = False 。FarEastLineBreakControl = True 。
WordWrap = True 。 HangingPunctuation = True 。
HalfWidthPunctuationOnTopOfLine = False 。AddSpaceBetweenFarEastAndAlpha = True 。
AddSpaceBetweenFarEastAndDigit = True 。BaseLineAlignment = wdBaselineAlignAuto End With Selection。
Font。 Color = wdColorBlack End Sub 祝你成功,请见附件:。
四、自己编写的word宏文件存放在哪个文件夹里
word宏文件是依附与word文档文件而存在的,你在录制或编写宏的时候可以选择它的保存位置,也就是依附与谁,但默认是保存与normal.dot文件中的.这个文件的一般位置是
C:\Documents and Settings\Administrator\Application Data\Microsoft\Templates 依据你的用户名和系统位置可能会有不同.
按alt+f11键,在左边的管理器的相应文件下的模块文件夹下能找到你的宏代码.
五、在WORD文件里设置一个宏
“把这个空格键的字符间距缩放为1%“--------------这个间距太小了吧?
代码如下:
Sub 插入小空格()
'
' Selection.TypeText Text:=" "
Selection.InsertSymbol CharacterNumber:=8194, Unicode:=True, Bias:=0
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
With Selection.Font
.NameFarEast = "宋体"
.NameAscii = "Times New Roman"
.NameOther = "Times New Roman"
.Name = "Times New Roman"
.Size = 10.5
.Bold = False
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
.StrikeThrough = False
.DoubleStrikeThrough = False
.Outline = False
.Emboss = False
.Shadow = False
.Hidden = False
.SmallCaps = False
.AllCaps = False
.Color = wdColorAutomatic
.Engrave = False
.Superscript = False
.Subscript = False
.Spacing = 0
.Scaling = 1
.Position = 0
.Kerning = 1
.Animation = wdAnimationNone
.DisableCharacterSpaceGrid = False
.EmphasisMark = wdEmphasisMarkNone
End With
End Sub
转载请注明出处51数据库 » word宏一个文件夹