J
justalostgrunt
Hi,
What worked six months ago seems to give a runtime error now.
Revisting a VBA routine as the project has come out of moth balls.
error 13 - type mismatch on the line:
Set bmrange = destdoc11.Bookmarks("section11").Range ' locate the bookmark
In the snippet of the whole routine,
If Dir(strAtt) = "" Then
MsgBox "File does not exist"
Else
Set srcDoc = Wordapp.Documents.Open(strAtt) 'attachment sheet
End If
'open the letter
Set destdoc11 = Wordapp.Documents.Open(strInputFileName) 'letter
Set bmrange = destdoc11.Bookmarks("section11").Range ' locate the bookmark
'create new section - add a page past the bookmark
destdoc11.Bookmarks("section11").Range.InsertBreak
Type:=wdSectionBreakNextPage
're-insert the bookmark as we have removed it by the section break
destdoc11.Bookmarks.Add "section11", bmrange
'copy the text and replace the bookmark
bmrange.FormattedText = srcDoc.Range.FormattedText
destdoc11.close (wdSaveChanges)
'close the Attachment sheet
srcDoc.close (wdDoNotSaveChanges)
I retraced my steps revisted posts from April and use of bookmarks on the
FAQ word site and I can't see what could cause this glitch.
Corrupt VBA or the bookmarks in the original letter?
Any ideas appreciated.
Regards
bill
What worked six months ago seems to give a runtime error now.
Revisting a VBA routine as the project has come out of moth balls.
error 13 - type mismatch on the line:
Set bmrange = destdoc11.Bookmarks("section11").Range ' locate the bookmark
In the snippet of the whole routine,
If Dir(strAtt) = "" Then
MsgBox "File does not exist"
Else
Set srcDoc = Wordapp.Documents.Open(strAtt) 'attachment sheet
End If
'open the letter
Set destdoc11 = Wordapp.Documents.Open(strInputFileName) 'letter
Set bmrange = destdoc11.Bookmarks("section11").Range ' locate the bookmark
'create new section - add a page past the bookmark
destdoc11.Bookmarks("section11").Range.InsertBreak
Type:=wdSectionBreakNextPage
're-insert the bookmark as we have removed it by the section break
destdoc11.Bookmarks.Add "section11", bmrange
'copy the text and replace the bookmark
bmrange.FormattedText = srcDoc.Range.FormattedText
destdoc11.close (wdSaveChanges)
'close the Attachment sheet
srcDoc.close (wdDoNotSaveChanges)
I retraced my steps revisted posts from April and use of bookmarks on the
FAQ word site and I can't see what could cause this glitch.
Corrupt VBA or the bookmarks in the original letter?
Any ideas appreciated.
Regards
bill