K
Kragelund
Hi,
this (part of a ) procedure has worked for several months, now its suddenly
failing, when implemented in a new worksheet. Apparently the procedure now
doen't recognise the reference to a bookmark in Word.
The procedure now stops at "wdGoToBookmark", where I get the error message
"compile error - can't find project or library".
The difference between the functioning version and the version that doesn't
perform is that the former references to a word 11 library, while the latter
refers to a Word 12 library. In the non-performing version, I can't selecxt
the word 11 library. I think this may be where the problem is. Is there a way
out?
The code:
Sub Xl_to_Word()
Dim h, i, j, k As Integer
Dim name As Variant
'Dim wdGoToBookmark, wdPasteText, wdInLine As Variant
Dim WordRep As Object
Set WordRep = CreateObject("Word.Application")
Application.ScreenUpdating = False
Application.CutCopyMode = False
WordRep.Documents.Open "G:\plan.doc"
WordRep.Visible = True
For k = 1 To 6 'Insert acronyms in the document
worksheets("Statusark").Range("c66").Copy
WordRep.Selection.GoTo what:=wdGoToBookmark, name:="PR1_rep" & k
WordRep.Selection.PasteSpecial Link:=False, DataType:=wdPasteText,
Placement:=wdInLine, DisplayAsIcon:=False
worksheets("Statusark").Range("E66").Copy
WordRep.Selection.GoTo what:=wdGoToBookmark, name:="PR2_rep" & k
WordRep.Selection.PasteSpecial Link:=False, DataType:=wdPasteText,
Placement:=wdInLine, DisplayAsIcon:=False
Next k
..
..
..
End sub
this (part of a ) procedure has worked for several months, now its suddenly
failing, when implemented in a new worksheet. Apparently the procedure now
doen't recognise the reference to a bookmark in Word.
The procedure now stops at "wdGoToBookmark", where I get the error message
"compile error - can't find project or library".
The difference between the functioning version and the version that doesn't
perform is that the former references to a word 11 library, while the latter
refers to a Word 12 library. In the non-performing version, I can't selecxt
the word 11 library. I think this may be where the problem is. Is there a way
out?
The code:
Sub Xl_to_Word()
Dim h, i, j, k As Integer
Dim name As Variant
'Dim wdGoToBookmark, wdPasteText, wdInLine As Variant
Dim WordRep As Object
Set WordRep = CreateObject("Word.Application")
Application.ScreenUpdating = False
Application.CutCopyMode = False
WordRep.Documents.Open "G:\plan.doc"
WordRep.Visible = True
For k = 1 To 6 'Insert acronyms in the document
worksheets("Statusark").Range("c66").Copy
WordRep.Selection.GoTo what:=wdGoToBookmark, name:="PR1_rep" & k
WordRep.Selection.PasteSpecial Link:=False, DataType:=wdPasteText,
Placement:=wdInLine, DisplayAsIcon:=False
worksheets("Statusark").Range("E66").Copy
WordRep.Selection.GoTo what:=wdGoToBookmark, name:="PR2_rep" & k
WordRep.Selection.PasteSpecial Link:=False, DataType:=wdPasteText,
Placement:=wdInLine, DisplayAsIcon:=False
Next k
..
..
..
End sub