VBA-VB 为什么运行后,指“Content”未找到方法或数据成员,谢谢

ygxshanghai 2012-08-28 03:04:29
Option Explicit

Private Sub Command1_Click()
Dim oApp As Word.Application
Dim oDoc As Word.Document
Set oApp = New Word.Application
oApp.Visible = True
Set oDoc = oApp.Documents.Add

oApp.Content.Font.Name = "宋体"
oApp.Content.Font.Size = 16
oApp.Content.Paragraphs.LineSpacing = 3
oApp.Paragraphs(oApp.Paragraphs.Count).Alignment = wdAlignParagraphCenter
oApp.Paragraphs(oApp.Paragraphs.Count).Range.Font.Bold = True

oApp.ActiveWindow.Selection.TypeText "(题目)" & vbCrLf

oApp.Content.Paragraphs.LineSpacing = 3
oApp.Paragraphs(oApp.Paragraphs.Count).Alignment = wdAlignParagraphLeft
oApp.Paragraphs(oApp.Paragraphs.Count).Range.Font.Bold = False
oApp.Paragraphs(oApp.Paragraphs.Count).Range.Font.Size = 11

oDoc.SaveAs App.Path & "\(题目).doc"

oDoc.Close
oApp.Quit
Set oDoc = Nothing
Set oApp = Nothing
End Sub
...全文
185 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
oApp.Content 改成 oDoc.Content
  • 打赏
  • 举报
回复
oApp.Content 改成 oDoc.Content.Font

2,462

社区成员

发帖
与我相关
我的任务
社区描述
VBA(Visual Basic for Applications)是Visual Basic的一种宏语言,是在其桌面应用程序中执行通用的自动化(OLE)任务的编程语言。
社区管理员
  • VBA
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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