100高分求Word宏问题,急啊,高手请进啊

hnxzl2008 2005-12-06 11:08:09
有个宏:

Sub Macro3()
'
' Macro3 Macro
' 宏在 2005-12-4 由 kkk 录制
'
Selection.Style = ActiveDocument.Styles("标题 1")
End Sub

请问高手这个宏如何用c#实现?
我写的代码是
wordApp.Selection.Style = wordApp.ActiveDocument.Styles.Add("标题 1",ref missing);
但是实现不了,请问高手如何实现?
...全文
312 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
hnxzl2008 2005-12-10
  • 打赏
  • 举报
回复
实现了,但是不是c#的是vb.net的:
Public Sub HB(ByVal filepath As String, ByVal titles As String)
Dim wdstypeheading1 As Object '合并函数
wdstypeheading1 = "标题 1"

wordApp.Selection.Style = wordApp.ActiveDocument.Styles.Item(wdstypeheading1)

wordApp.Selection.TypeText(titles)
wordApp.Selection.TypeParagraph()
wordApp.Selection.InsertFile(filepath, missing, missing, missing, missing)
wordApp.Selection.EndKey(missing, missing)
End Sub
有些东西c#可能是实现不了的
hnxzl2008 2005-12-10
  • 打赏
  • 举报
回复
object wdstypeheading1 = "标题 1";

wordApp.Selection.ParagraphFormat=wordApp.ActiveDocument.Styles.Item(ref wdstypeheading1).ParagraphFormat;

以上两句可以实现样式,但不是标题1的样式。
但是
wordApp.Selection.Style=wordApp.ActiveDocument.Styles.Item(wdstypeheading1);
运行不通,高手指点啊。

wntpfi 2005-12-09
  • 打赏
  • 举报
回复
发人个资料看看。
northwolves 2005-12-08
  • 打赏
  • 举报
回复
老蒋正解
蒋晟 2005-12-07
  • 打赏
  • 举报
回复
Selection.Style = "标题 1";
Mr_Yang 2005-12-06
  • 打赏
  • 举报
回复
旺一下人气!
northwolves 2005-12-06
  • 打赏
  • 举报
回复
这里人气不够旺.以后有问题欢迎到我们VB版.
northwolves 2005-12-06
  • 打赏
  • 举报
回复
wordApp.Selection.Style =wordApp.ActiveDocument.Styles(wdStyleHeading1)
hnxzl2008 2005-12-06
  • 打赏
  • 举报
回复
这样写不行啊,编译错误。
wordApp.ActiveDocument.Styles是属性不是方法。
请高手多帮忙啊
northwolves 2005-12-06
  • 打赏
  • 举报
回复
wordApp.Selection.Style = wordApp.ActiveDocument.Styles("标题 1)

5,139

社区成员

发帖
与我相关
我的任务
社区描述
其他开发语言 Office开发/ VBA
社区管理员
  • Office开发/ VBA社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧