G
grasping@straws
The following code works in Word (from a toolbar button) to switch
from the
open Word document to the open Excel worksheet (& then run an Excel
macro to
paste into a cell).
----------------------------------------------------------------------------
Sub CopyToExcel()
'
'
Dim xlObj As Object
Selection.Copy
Set xlObj = GetObject(, "Excel.Application")
xlObj.Visible = True
xlObj.Run "PasteTab"
Set xlObj = Nothing
End Sub
----------------------------------------------------------------------------
Tried a variation of same (as below, using "wdrObj" instead of "xlObj"
throughout),
tied to a Worksheet_SelectionChange (ByVal, TargetAsRange) event - so
it
would switch back to the open Word document for the next selection -
but it
wouldn't work. Why not?
----------------------------------------------------------------------------
Sub SwitchToWordl()
'
'
Dim wrdObj As Object
Set wrdObj = GetObject(, "Word.Application")
wrdObj.Visible = True
Set wrdObj = Nothing
End Sub
from the
open Word document to the open Excel worksheet (& then run an Excel
macro to
paste into a cell).
----------------------------------------------------------------------------
Sub CopyToExcel()
'
'
Dim xlObj As Object
Selection.Copy
Set xlObj = GetObject(, "Excel.Application")
xlObj.Visible = True
xlObj.Run "PasteTab"
Set xlObj = Nothing
End Sub
----------------------------------------------------------------------------
Tried a variation of same (as below, using "wdrObj" instead of "xlObj"
throughout),
tied to a Worksheet_SelectionChange (ByVal, TargetAsRange) event - so
it
would switch back to the open Word document for the next selection -
but it
wouldn't work. Why not?
----------------------------------------------------------------------------
Sub SwitchToWordl()
'
'
Dim wrdObj As Object
Set wrdObj = GetObject(, "Word.Application")
wrdObj.Visible = True
Set wrdObj = Nothing
End Sub