Hi,
I have an error which I cannot find any info on. It is error 5850 ('The Specified range is not from the correct document or story')
I am trying to transfer data
The error appears directly above the ?????????????????????? (the 2 lines below I commented out - see later):
Code:
Dim rngSupply As Word.Range
Set rngSupply = ActiveDocument.Bookmarks("bmSupply").Range
Dim rngSupplyBody As Word.Range
Set rngSupplyBody = ActiveDocument.Bookmarks("bmSupplyBody").Range
Dim rngSupplyBreak As Range
Set rngSupplyBreak = ActiveDocument.Bookmarks("bmSupplyBreak").Range
Call RetrieveExcelData
If Me.chkSupply.Value = True Then
rngSupply.Text = vbNewLine & "Scope of Supply" & vbNewLine
ActiveDocument.Bookmarks.Add "bmSupply", rngSupply
???????????????????????????????????????????????????????
rngSupplyBody.Text = docSupply.Bookmarks("test").Range & vbNewLine
ActiveDocument.Bookmarks.Add "test", rngSupplyBody
rngSupplyBreak.Select
Selection.Range.InsertBreak (wdPageBreak)
ActiveDocument.Bookmarks.Add "bmSupplyBreak", rngSupplyBreak
As I stated above I commented out the 2 lines but that didn't do anything. I then commented out the code below and the error disappeared:
Code:
Function RetrieveExcelData()
'Scope of Supply Document
Public appSupply As Word.Application
Public docSupply As Word.Document
Set appSupply = Word.Application
Set docSupply = appSupply.Documents.Open("H:\proposalDocumentDevelopment\proposalTemplates\scopeOfSupply.docx")
End Function
Can anybody help? I might have just written the wrong transfer code for inserting data from one word dcoument to another.
Thanks