2017-08-25 58 views
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 
+0

您是否拥有E的写入权限? – braX

+0

我实际上不知道如何检查它,它只是一个闪存驱动器,我把我所有的工作保存到 – Cocoberry2526

+0

如果将该行更改为“ActiveDocument.SaveAs Fullname”,会发生什么情况? – braX

回答