0
我一直在這幾天工作了幾天,試圖讓運行時5487錯誤消失,但沒有任何運氣。我將不勝感激任何幫助,我可以得到這一點。出現該錯誤的一行:微軟Word VBA:修復運行時間5487錯誤
ActiveDocument.SaveAs Fullname, fileformat:=wdFormatXMLDocument, AddToRecentFiles:=False.
文件路徑名出來爲E:\assessment_rubrics\Program Art-Teaching Certif BA BS .docx
,當我debug.print它。
Function cvtstr(strIn As String) As String
Dim i As Integer
Const str = "/|?*<>"":"
cvtstr = strIn
For i = 1 To Len(str)
cvtstr = Replace(cvtstr, Mid$(str, i, 1), " ")
Next i
End Function
Sub Splitter()
' splitter Macro
' Macro created by Doug Robbins to save each letter created by a mailmergeas a separate file.
Application.ScreenUpdating = False
Dim Program As String
Dim DocName As String
Dim Letters As Integer, Counter As Integer
Dim file_name, extension, Fullname, filepath, Mask As String
Letters = ActiveDocument.Sections.Count
Selection.HomeKey Unit:=wdStory
Counter = 1
While Counter < Letters
'program = ActiveDocument.MailMerge.DataSource.DataFields("Program_Outcomes_PlanReport_Name").Value
DocName = "Reports" & LTrim$(str$(Counter)) 'Generic name of document
ActiveDocument.Sections.First.Range.Cut
Documents.Add
Selection.Paste
'ActiveDocument.Sections(2).PageSetup.SectionStart = wdSectionContinuous
file_name = cvtstr(ActiveDocument.Paragraphs(1).Range.Text)
file_name = Left(file_name, Len(file_name) - 1)
extension = ".docx"
DocName = "E:\assessment_rubrics\" & filename & file_name
Fullname = DocName & extension
Debug.Print Fullname
Debug.Print file_name
ActiveDocument.SaveAs Fullname, fileformat:=wdFormatXMLDocument, AddToRecentFiles:=False
ActiveWindow.Close
Counter = Counter + 1
Wend
Application.ScreenUpdating = True
End Sub
您是否擁有E的寫入權限? – braX
我實際上不知道如何檢查它,它只是一個閃存驅動器,我把我所有的工作保存到 – Cocoberry2526
如果將該行更改爲「ActiveDocument.SaveAs Fullname」,會發生什麼情況? – braX