ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel to Word and back again (https://www.excelbanter.com/excel-programming/353514-excel-word-back-again.html)

Rominall

Excel to Word and back again
 
I have the following code.
Range("A7:N7").Select
Selection.Copy
Dim appWD As Word.Application
Dim odoc As Word.Document
Set appWD = CreateObject("Word.Application")
appWD.Visible = True
Set odoc = appWD.Documents.Add
odoc.Range.PasteExcelTable False, False, False
Set appWD = Nothing

And it works but I want to copy multiple ranges, I can set up the loop
required but how do I switch back and forth between the applications. When I
try Application.ActivateMicrosoftApp xlMicrosoftExcel it brings up the
calculator????



Ed

Excel to Word and back again
 
You should have an object set to your Excel Workbook.
objYourXLWKbObject.Activate should be what you need.
Ed

"Rominall" wrote in message
...
I have the following code.
Range("A7:N7").Select
Selection.Copy
Dim appWD As Word.Application
Dim odoc As Word.Document
Set appWD = CreateObject("Word.Application")
appWD.Visible = True
Set odoc = appWD.Documents.Add
odoc.Range.PasteExcelTable False, False, False
Set appWD = Nothing

And it works but I want to copy multiple ranges, I can set up the loop
required but how do I switch back and forth between the applications.

When I
try Application.ActivateMicrosoftApp xlMicrosoftExcel it brings up the
calculator????






All times are GMT +1. The time now is 12:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com