ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 效率神器,一键搞定繁琐工作
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
让更多数据处理,一键完成 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
查看: 2306|回复: 6

[求助]如何让宏1运行结束后自动在文档第二栏运行宏2

[复制链接]

TA的精华主题

TA的得分主题

发表于 2006-11-18 22:03 | 显示全部楼层 |阅读模式
我录制了下面两个宏,请问如何让宏1运行结束后自动在文档第二栏运行宏2
谢谢告知!!!
宏是在WORD2007下录制的~~~~
Sub 宏1()

    If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
        ActiveWindow.Panes(2).Close
    End If
    If ActiveWindow.ActivePane.View.Type <> wdPrintView Then
        ActiveWindow.ActivePane.View.Type = wdPrintView
    End If
    With ActiveDocument.PageSetup.TextColumns
        .SetCount NumColumns:=1
        .EvenlySpaced = False
        .LineBetween = False
    End With
    ActiveDocument.Shapes.AddTextbox(msoTextOrientationVerticalFarEast, 12# _
        , 78#, 57#, 692.25).Select

    Selection.Collapse
    
    Selection.Orientation = wdTextOrientationHorizontal
    Selection.TypeText Text:="姓名"
  
    Selection.Orientation = wdTextOrientationUpward
    Selection.Font.Underline = wdUnderlineSingle
    Selection.Font.Underline = wdUnderlineThick
    Selection.TypeText Text:="              "
    Selection.Font.UnderlineColor = wdColorAutomatic
    Selection.Font.Underline = wdUnderlineSingle
    
    
    Selection.Font.UnderlineColor = wdColorAutomatic
    Selection.Font.Underline = wdUnderlineNone
    Selection.TypeText Text:="班级"
    Selection.Font.UnderlineColor = wdColorAutomatic
    Selection.Font.Underline = wdUnderlineThick
    Selection.TypeText Text:="                   "
    Selection.Font.UnderlineColor = wdColorAutomatic
    Selection.Font.Underline = wdUnderlineNone
    Selection.TypeText Text:="考号"
    Selection.Font.UnderlineColor = wdColorAutomatic
    Selection.Font.Underline = wdUnderlineThick
    Selection.TypeText Text:="                     "
    Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
    Selection.TypeParagraph
  
     Selection.TypeParagraph
    Selection.TypeText Text:= _
        "★★★┄┄┄密┄┄★★★┄┄封┄┄★★★┄┄线 ┄┄★★★┄┄ 内┄┄★★★┄┄不 ┄┄★★★┄┄得┄┄★★★"
    Selection.TypeText Text:="┄┄答┄┄★★★┄┄ 题┄┄┄★★★"
    
  Selection.ShapeRange.Line.Visible = msoFalse
   Selection.ShapeRange.ScaleHeight 1.1, msoFalse, msoScaleFromBottomRight
    Selection.ShapeRange.ScaleHeight 1.09, msoFalse, msoScaleFromTopLeft

End Sub
Sub 宏2()
'
' 宏2 宏
'
'

    
    Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
    Selection.Font.Size = 24
    Selection.Font.Name = "宋体"
    Selection.TypeText Text:="肥东县张集中学九年级月考"
    Selection.TypeParagraph
    Selection.Font.Size = 18
    Selection.Font.Name = "楷体_GB2312"
    Selection.TypeText Text:="化 学 试 卷"
    Selection.TypeParagraph
    Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
    Selection.Font.Size = 12
    Selection.Font.Name = "宋体"
    Selection.TypeText Text:= _
        "可能用到的相对原子质量:H:1    16   C: 12  P: 31  S: 32  Si: 28 "
    Selection.TypeParagraph
    Selection.TypeText Text:= _
        "Cl: 35.5  Na: 23 Mg: 24  Al: 27  Fe: 56 Cu:64  Zn:65  Mn: 55"
    Selection.TypeParagraph
    With ListGalleries(wdOutlineNumberGallery).ListTemplates(1).ListLevels(1)
        .NumberFormat = "%1"
        .TrailingCharacter = wdTrailingTab
        .NumberStyle = wdListNumberStyleSimpChinNum3
        .NumberPosition = CentimetersToPoints(0)
        .Alignment = wdListLevelAlignLeft
        .TextPosition = CentimetersToPoints(0.75)
        .TabPosition = wdUndefined
        .ResetOnHigher = 0
        .StartAt = 1
        With .Font
            .Bold = wdUndefined
            .Italic = wdUndefined
            .StrikeThrough = wdUndefined
            .Subscript = wdUndefined
            .Superscript = wdUndefined
            .Shadow = wdUndefined
            .Outline = wdUndefined
            .Emboss = wdUndefined
            .Engrave = wdUndefined
            .AllCaps = wdUndefined
            .Hidden = wdUndefined
            .Underline = wdUndefined
            .Color = wdUndefined
            .Size = wdUndefined
            .Animation = wdUndefined
            .DoubleStrikeThrough = wdUndefined
            .Name = ""
        End With
        .LinkedStyle = ""
    End With
    

    With ListGalleries(wdOutlineNumberGallery).ListTemplates(1).ListLevels(9)
        .NumberFormat = "%1.%2.%3.%4.%5.%6.%7.%8.%9"
        .TrailingCharacter = wdTrailingTab
        .NumberStyle = wdListNumberStyleArabic
        .NumberPosition = CentimetersToPoints(6)
        .Alignment = wdListLevelAlignLeft
        .TextPosition = CentimetersToPoints(9)
        .TabPosition = wdUndefined
        .ResetOnHigher = 8
        .StartAt = 1
        With .Font
            .Bold = wdUndefined
            .Italic = wdUndefined
            .StrikeThrough = wdUndefined
            .Subscript = wdUndefined
            .Superscript = wdUndefined
            .Shadow = wdUndefined
            .Outline = wdUndefined
            .Emboss = wdUndefined
            .Engrave = wdUndefined
            .AllCaps = wdUndefined
            .Hidden = wdUndefined
            .Underline = wdUndefined
            .Color = wdUndefined
            .Size = wdUndefined
            .Animation = wdUndefined
            .DoubleStrikeThrough = wdUndefined
            .Name = ""
        End With
        .LinkedStyle = ""
    End With
    ListGalleries(wdOutlineNumberGallery).ListTemplates(1).Name = ""
    Selection.Range.ListFormat.ApplyListTemplateWithLevel ListTemplate:= _
        ListGalleries(wdOutlineNumberGallery).ListTemplates(1), _
        ContinuePreviousList:=False, ApplyT=wdListApplyToWholeList, _
        DefaultListBehavior:=wdWord10ListBehavior
    Selection.TypeText Text:="选择题"
    Selection.TypeParagraph
    Selection.TypeText Text:="填空题"
    Selection.TypeParagraph
    Selection.TypeText Text:="简答题"
    Selection.TypeParagraph
    Selection.TypeText Text:="计算题"
End Sub
CsxMiFrY.rar (1.51 KB, 下载次数: 10)
[此贴子已经被作者于2006-11-19 8:48:18编辑过]

TA的精华主题

TA的得分主题

发表于 2006-11-18 22:08 | 显示全部楼层
在宏1的End Sub 前一行,插入call 宏2

TA的精华主题

TA的得分主题

 楼主| 发表于 2006-11-18 22:28 | 显示全部楼层
这样不行,你可以试一下!!!~~~~~~~因为当前选中文本框
[此贴子已经被作者于2006-11-18 22:31:10编辑过]

TA的精华主题

TA的得分主题

发表于 2006-11-18 22:47 | 显示全部楼层
用附件。只是粘粘到论坛时,代码变形(被过滤)。
[此贴子已经被作者于2006-11-18 22:48:40编辑过]

TA的精华主题

TA的得分主题

发表于 2006-11-19 09:25 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册

无法具体知道楼主的确切意思,试一下这个:

在宏1的结束位置前,加上:

  ActiveDocument.Range(0, 0).Select
    Call 宏2
End Sub

TA的精华主题

TA的得分主题

 楼主| 发表于 2006-11-19 09:36 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
谢谢,可以的,呵呵!可以解释一下吗?

TA的精华主题

TA的得分主题

发表于 2006-11-19 09:45 | 显示全部楼层
QUOTE:
以下是引用zhangxdong4在2006-11-19 9:36:38的发言:
谢谢,可以的,呵呵!可以解释一下吗?

你无非是想退出文本框编辑,在起始位置设置其它内容吧,所以用了这个:

Activedocument.range(0,0).select

您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-11-17 04:27 , Processed in 0.041741 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

快速回复 返回顶部 返回列表