PDA

View Full Version : Returning to Excel from Paste in Word



JvL
09-25-2007, 05:14 AM
Dear all,

I used the following code to paste a table from excel into my active word document. Afther that i like to return to excel without saving or quiting word, just "activate" excel.

Code:


Public Sub TEST()
Dim wdApp As Object

Dim xlApp As Object
Dim MyFile As String
Set wdApp = GetObject(, "Word.Application")
Set xlApp = GetObject(, "Excel.Application")
Worksheets("Blad3").Activate
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.RowHeight = 9
Rows("2:2").Select
Selection.RowHeight = 15
Cells.Select
Selection.Copy


With wdApp.Visible = True
If wdApp.Visible = False Then
MsgBox Prompt:="U heeft op dit moment geen Word-document geopend"
Exit Sub
Else
wdApp.Activate
Set WordDoc = wdApp.ActiveDocument
End If
End With
With wdApp
.Selection.Paste
.Selection.InsertBreak wdPageBreak
End With
Set wdApp = Nothing

End Sub


Who can help me?

Thx. JvL

rory
09-25-2007, 05:20 AM
Have you tried adding:
AppActivate "Microsoft Excel"
to the end?

JvL
09-25-2007, 05:24 AM
YES:beerchug: Problem Solved!!

Thx JvL