Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 509
Default 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   Report Post  
Posted to microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 509
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Activate new window Robert Rosenberg[_2_] Excel Programming 0 December 30th 03 04:46 PM
Activate new window Tom Ogilvy Excel Programming 0 December 30th 03 04:37 PM
Activate Non-Excel Window Through VBA Mark Bigelow Excel Programming 1 September 3rd 03 07:37 PM
using excel macro to activate word document Amy[_4_] Excel Programming 1 August 12th 03 12:40 AM
How to keep window + form activate together John Brash Excel Programming 1 July 24th 03 10:13 AM


All times are GMT +1. The time now is 04:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"