Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
activate a Word Window from Excel VBA
I have a lot of cell data from excell I am Transfering to a Word document
that will be manually opened, I want to know how to switch from excel to having the Word document the Active window so that I can perform the sendkeys statement to that window. Sub saywhat() On erorr GoTo yui Application.Interactive = False Application.Windows("file.doc").Activate For m = 2 To Sheet1.UsedRange.Rows.Count Cells(m, 4).Value = Application.WorksheetFunction.Proper(Cells(m, 4).Value) stfw = " " + Cells(m, 2).Value + ", " + Cells(m, 3).Value + _ Chr$(13) + Left(Cells(m, 1).Value, 2) _ + " " + Cells(m, 4).Value + Chr$(9) If m / 2 = Int(m / 2) Then stfw = stfw + Chr$(9) SendKeys stfw, Wait:=True Next yui: Application.Interactive = True End Sub that is the code in it's entirety, it will send the keys all right but i need it to send it to the Word Doc "files.doc" |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
activate a Word Window from Excel VBA
I always seem to find the answer before someone helps me. haha here is the
ammended code Sub saywhat() On erorr GoTo yui channelNumber = Application.DDEInitiate( _ app:="WinWord", _ topic:="C:\files.doc") Application.DDEExecute channelNumber, "[ACTIVATE ""files.doc""]" For m = 2 To Sheet1.UsedRange.Rows.Count Cells(m, 4).Value = Application.WorksheetFunction.Proper(Cells(m, 4).Value) stfw = " " + Cells(m, 2).Value + ", " + Cells(m, 3).Value + _ Chr$(13) + Left(Cells(m, 1).Value, 2) _ + " " + Cells(m, 4).Value + Chr$(9) If m / 2 = Int(m / 2) Then stfw = stfw + Chr$(9) SendKeys stfw, Wait:=True Next DDETerminate 3 yui: End Sub "ben" wrote: I have a lot of cell data from excell I am Transfering to a Word document that will be manually opened, I want to know how to switch from excel to having the Word document the Active window so that I can perform the sendkeys statement to that window. Sub saywhat() On erorr GoTo yui Application.Interactive = False Application.Windows("file.doc").Activate For m = 2 To Sheet1.UsedRange.Rows.Count Cells(m, 4).Value = Application.WorksheetFunction.Proper(Cells(m, 4).Value) stfw = " " + Cells(m, 2).Value + ", " + Cells(m, 3).Value + _ Chr$(13) + Left(Cells(m, 1).Value, 2) _ + " " + Cells(m, 4).Value + Chr$(9) If m / 2 = Int(m / 2) Then stfw = stfw + Chr$(9) SendKeys stfw, Wait:=True Next yui: Application.Interactive = True End Sub that is the code in it's entirety, it will send the keys all right but i need it to send it to the Word Doc "files.doc" |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Activate new window | Excel Programming | |||
Activate new window | Excel Programming | |||
Activate Non-Excel Window Through VBA | Excel Programming | |||
using excel macro to activate word document | Excel Programming | |||
How to keep window + form activate together | Excel Programming |