EDN Admin
Well-known member
I am using this code to open a sheet embedded in a word 2010 document. I cannot figure out how to initialize variables, etc., so that I can move to the cell I want to go to (next open cell in Column A) and paste data. I am consistently getting
this error:
Run-time error 1004: Select method of Range class failed with this code.
Other incarnations have resulted in
Run-time error 1004 Method Worksheets of object _Global failed
Would really appreciate help with getting this working.
<pre class="prettyprint Language is VBA, which is not a choice from the menu
Sub ThuMacro2()
ThuMacro2 Macro
Selection.GoTo What:=wdGoToBookmark, Name:="HIDTable"
With ActiveDocument.Bookmarks
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
Selection.Copy
Dim oWB As Workbook
Dim oWS As Worksheet
Dim oIShape As InlineShape
For Each oIShape In ActiveDocument.InlineShapes
If InStr(1, oIShape.OLEFormat.ProgID, "Excel") Then
oIShape.OLEFormat.Activate
Set oWB = oIShape.OLEFormat.Object
Set oWS = oWB.Sheets("Sheet1")
oWB.Activate
oWS.Activate
oWS.Visible = True
From Here
oWS.Range("A3:A5").Select
oWS.Range("A3").Value = "Frustrated"
oWS.Range("A3").End(xlDown).Select
oWS.ActiveCell.Offset(1, 0).Select
oWS.PasteSpecial Format:="Text", _
Link:=False, DisplayAsIcon:= _
False
To Here
End If
Next oIShape
End Sub[/code]
<br/>
<hr class="sig Debbie B Carson
View the full article
this error:
Run-time error 1004: Select method of Range class failed with this code.
Other incarnations have resulted in
Run-time error 1004 Method Worksheets of object _Global failed
Would really appreciate help with getting this working.
<pre class="prettyprint Language is VBA, which is not a choice from the menu
Sub ThuMacro2()
ThuMacro2 Macro
Selection.GoTo What:=wdGoToBookmark, Name:="HIDTable"
With ActiveDocument.Bookmarks
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
Selection.Copy
Dim oWB As Workbook
Dim oWS As Worksheet
Dim oIShape As InlineShape
For Each oIShape In ActiveDocument.InlineShapes
If InStr(1, oIShape.OLEFormat.ProgID, "Excel") Then
oIShape.OLEFormat.Activate
Set oWB = oIShape.OLEFormat.Object
Set oWS = oWB.Sheets("Sheet1")
oWB.Activate
oWS.Activate
oWS.Visible = True
From Here
oWS.Range("A3:A5").Select
oWS.Range("A3").Value = "Frustrated"
oWS.Range("A3").End(xlDown).Select
oWS.ActiveCell.Offset(1, 0).Select
oWS.PasteSpecial Format:="Text", _
Link:=False, DisplayAsIcon:= _
False
To Here
End If
Next oIShape
End Sub[/code]
<br/>
<hr class="sig Debbie B Carson
View the full article