我正在尝试运行Excel子程序来保存Word文档。
语言版本: Word/Excel版本16.41
操作系统: Mac 10.14.6
我试过:(文件/文件)
我从零开始在不同的计算机和操作系统上工作。我现在使用Majave 10.14.6和Word/Excel版本16.41。我能够打开工具--引用--并选择单词库,但是现在引用没有高亮显示,也是不可点击的。(在此之前也是短暂的)
我遇到:
运行时错误-2146959355 (80080005)自动化错误。
需要调试的行:
Set wdApp = New Word.Application
Option Explicit
Sub CreateBasicWordReportEarlyBinding()
Dim wdApp As Word.Application
Set wdApp = New Word.Application
With wdApp
.Visible = True
.Activate
.Documents.Add
With .Selection
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.BoldRun
.Font.Size = 18
.TypeText "Best Movies Ever"
.BoldRun
.Font.Size = 12
.TypeText vbNewLine
.ParagraphFormat.Alignment = wdAlignParagraphLeft
.TypeParagraph
End With
Range("A2", Range("A2").End(xlDown).End(xlToRight)).Copy
.Selection.Paste
.ActiveDocument.SaveAs2 Environ("UserProfile") & "\Desktop\MovieReport.docx"
.ActiveDocument.Close
.Quit
End With
Set wdApp = Nothing
End Sub
发布于 2022-04-08 14:56:23
要找到保存到Mac文件夹的正确语法,请执行以下操作:
以Word 16 (2019)为例:
ActiveDocument.SaveAs2 FileName:= _
"/Users/myusername/anyfolder/nameofthefile" & DocNum & ".txt" _
, FileFormat:=wdFormatText, LockComments:=False, Password:="", _
AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _
:=False, SaveAsAOCELetter:=False, Encoding:=65001, InsertLineBreaks:= _
False, AllowSubstitutions:=False, LineEnding:=wdCROnly
https://stackoverflow.com/questions/64071777
复制相似问题