2017-08-25 18 views
0

ランタイム5487のエラーを取り除くためにこの同じビットで数日間働いていますが、運がなかったのです。私はこれに得ることができるすべての助けに感謝します。エラーが1行に発生します。MS Word VBA:ランタイム5487のエラーを修正しました

ActiveDocument.SaveAs Fullname, fileformat:=wdFormatXMLDocument, AddToRecentFiles:=False. 

ファイルのパス名は、私はそれをします。Debug.Print E:\assessment_rubrics\Program Art-Teaching Certif BA BS .docxとして出てきます。

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

答えて

関連する問題