sigrist
Programmer
- Apr 24, 2011
- 2
I am trying to export a Name: field from the current Word document and use it to create a directory on c:.
I have tried in Word 2007 and 2010.
I get a Run-time error '76': Path not found.
I cannot find the bug in my code, can you?
Thanks
Daniel
Sub CreateDirectory()
Mkdir("c:/" & ThatID("Name:"))
End Sub
Public Function ThatID(xx As String) As String
Dim ID As String
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = xx
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Copy
ID = Selection
Selection.EndKey Unit:=wdStory
ThatID = ID
End Function
I have tried in Word 2007 and 2010.
I get a Run-time error '76': Path not found.
I cannot find the bug in my code, can you?
Thanks
Daniel
Sub CreateDirectory()
Mkdir("c:/" & ThatID("Name:"))
End Sub
Public Function ThatID(xx As String) As String
Dim ID As String
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = xx
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Copy
ID = Selection
Selection.EndKey Unit:=wdStory
ThatID = ID
End Function