Access Beginner
Active Member
- Joined
- Nov 8, 2010
- Messages
- 311
- Office Version
- 2016
- Platform
- Windows
Hi,
I have a about 20 bookmarks to copy from Excel into Word. Below is an example of two Subs I call. The issue I have that sometimes it will run through these with no probs at all and at other times it will bug out with the error: "run time error 4605 this method or property is not available because the clipboard is empty or not valid". Is there something some can suggest to resolve the Intermittent error around the clipboard
I have a about 20 bookmarks to copy from Excel into Word. Below is an example of two Subs I call. The issue I have that sometimes it will run through these with no probs at all and at other times it will bug out with the error: "run time error 4605 this method or property is not available because the clipboard is empty or not valid". Is there something some can suggest to resolve the Intermittent error around the clipboard
Code:
.PasteSpecial Link:=False, DataType:=wdPasteText, Placement:= _
wdInLine, DisplayAsIcon:=False
Code:
Sub Goal5M1Notes()
Dim wdApp As Object
'Open new Word Document
On Error Resume Next
'Try to establish link to open instance of Word
Set wdApp = GetObject(, "Word.Application")
'If this fails, open Word
If wdApp Is Nothing Then
Set wdApp = GetObject("", "Word.Application")
End If
On Error GoTo 0
'Copy Excel Table of the Charts Sheet
ThisWorkbook.Sheets("Notes").Range("T10").Copy
With wdApp.Selection
.GoTo What:=wdGoToBookmark, Name:="Goal5M1Notes"
.PasteSpecial Link:=False, DataType:=wdPasteText, Placement:= _
wdInLine, DisplayAsIcon:=False
End With
'Release object variable
Set wdApp = Nothing
End Sub
Sub Goal5M2Notes()
Dim wdApp As Object
'Open new Word Document
On Error Resume Next
'Try to establish link to open instance of Word
Set wdApp = GetObject(, "Word.Application")
'If this fails, open Word
If wdApp Is Nothing Then
Set wdApp = GetObject("", "Word.Application")
End If
On Error GoTo 0
'Copy Excel Table of the Charts Sheet
ThisWorkbook.Sheets("Notes").Range("u10").Copy
With wdApp.Selection
.GoTo What:=wdGoToBookmark, Name:="Goal5M2Notes"
.PasteSpecial Link:=False, DataType:=wdPasteText, Placement:= _
wdInLine, DisplayAsIcon:=False
End With
'Release object variable
Set wdApp = Nothing
End Sub