U
Utsekaj
I'm am trying to use the following macro to extract text from an open file
and save it with the first line as the file name.
However the following Dialogue comes up
"
Runtime Error '5487'
Word cannot complete the save due to a file permissions error:
"
Can anyone tell me why this is happening and how I may fix it?
Sub CopyFormat()
'
' CopyFormat macro
'
'
Selection.Copy
Documents.Add Template:= _
"C:\Documents and Settings\user\My
Documents\Malaysia\Penan\Song.dotx", _
NewTemplate:=False, DocumentType:=0
Selection.PasteAndFormat Type:=wdFormatPlainText
Selection.HomeKey Unit:=wdStory
Selection.MoveDown Unit:=wdParagraph, Count:=1, Extend:=wdExtend
Selection.Style = ActiveDocument.Styles("Song Title")
Dim Title As String
Title = "C:\Documents and Settings\user\My
Documents\Malaysia\Penan\Songs\" & Selection.Text & ".docx"
Selection.EndKey Unit:=wdStory
Selection.Style = ActiveDocument.Styles("Normal")
With ActiveDocument.Styles("Normal").Font
.Name = "Times New Roman"
.Size = 14
.Bold = False
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
.StrikeThrough = False
.DoubleStrikeThrough = False
.Outline = False
.Emboss = False
.Shadow = False
.Hidden = False
.SmallCaps = False
.AllCaps = False
.Color = wdColorAutomatic
.Engrave = False
.Superscript = False
.Subscript = False
.Scaling = 100
.Kerning = 0
.Animation = wdAnimationNone
End With
With ActiveDocument.Styles("Normal")
.AutomaticallyUpdate = False
.BaseStyle = ""
.NextParagraphStyle = "Normal"
End With
ActiveDocument.SaveAs Title
ActiveWindow.Close
End Sub
and save it with the first line as the file name.
However the following Dialogue comes up
"
Runtime Error '5487'
Word cannot complete the save due to a file permissions error:
"
Can anyone tell me why this is happening and how I may fix it?
Sub CopyFormat()
'
' CopyFormat macro
'
'
Selection.Copy
Documents.Add Template:= _
"C:\Documents and Settings\user\My
Documents\Malaysia\Penan\Song.dotx", _
NewTemplate:=False, DocumentType:=0
Selection.PasteAndFormat Type:=wdFormatPlainText
Selection.HomeKey Unit:=wdStory
Selection.MoveDown Unit:=wdParagraph, Count:=1, Extend:=wdExtend
Selection.Style = ActiveDocument.Styles("Song Title")
Dim Title As String
Title = "C:\Documents and Settings\user\My
Documents\Malaysia\Penan\Songs\" & Selection.Text & ".docx"
Selection.EndKey Unit:=wdStory
Selection.Style = ActiveDocument.Styles("Normal")
With ActiveDocument.Styles("Normal").Font
.Name = "Times New Roman"
.Size = 14
.Bold = False
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
.StrikeThrough = False
.DoubleStrikeThrough = False
.Outline = False
.Emboss = False
.Shadow = False
.Hidden = False
.SmallCaps = False
.AllCaps = False
.Color = wdColorAutomatic
.Engrave = False
.Superscript = False
.Subscript = False
.Scaling = 100
.Kerning = 0
.Animation = wdAnimationNone
End With
With ActiveDocument.Styles("Normal")
.AutomaticallyUpdate = False
.BaseStyle = ""
.NextParagraphStyle = "Normal"
End With
ActiveDocument.SaveAs Title
ActiveWindow.Close
End Sub