运行时错误4605。此方法或属性不可用,因为文档窗口未处于活动状态 |
您所在的位置:网站首页 › 单元格处于活动状态是什么 › 运行时错误4605。此方法或属性不可用,因为文档窗口未处于活动状态 |
我正在尝试使用Word VBA在Outlook中创建约会,该约会基于打开包含宏的Word文档时加载的用户表单中提供的数据。 当宏执行粘贴功能时,我以运行时错误结束。 代码语言:javascript复制Dim OutApp As Object Dim OutMail As Object Dim OutInsp As Outlook.Inspector Dim WdApp As Word.Application Dim OutDoc As Word.Document Dim WdSel As Word.Selection Set OutApp = CreateObject("Outlook.Application") Set OutMail = OutApp.CreateItem(1) If request_Form.ComboBox3.Value = "****" Then With ActiveDocument.Bookmarks("recipient_Name") .Range.Text = "Uwe" End With With ActiveDocument.Bookmarks("applicant_Name") .Range.Text = Replace(request_Form.TextBox1.Value, "_", ", ") End With With OutMail .MeetingStatus = olMeeting .RequiredAttendees = "@live.in" .Subject = request_Form.TextBox1.Value & " Work From Home" .Location = "Home" .BusyStatus = olFree .ReminderSet = False If request_Form.CheckBox1.Value = False Then .Start = DateValue(request_Form.TextBox2.Value) + TimeValue(request_Form.ComboBox1.Value) .End = DateValue(request_Form.TextBox2.Value) + TimeValue(request_Form.ComboBox2.Value) Else .AllDayEvent = True End If .Display End With Set OutInsp = OutMail.GetInspector Set OutDoc = OutInsp.WordEditor Set WdApp = OutDoc.Application Set WdSel = WdApp.Windows(1).Selection Documents("Home Office Request Form.docm").Range.Copy With OutMail WdSel.PasteAndFormat Type:=wdFormatOriginalFormatting End With save_file MsgBox "A copy of this file has been stored in your desktop for your reference.", vbOKOnly + vbInformation, "Status Information" End Sub程序根据用户表单中填写的数据创建约会,并将整个内容复制到Word文档中并粘贴到约会的正文中。 当执行wdsel.pasteandformat时,它会导致运行时错误。这种错误并不经常发生,所以很难理解出了什么问题。假设它有70%的时间是有效的。 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |