View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
ryguy7272 ryguy7272 is offline
external usenet poster
 
Posts: 2,836
Default Automating a copy from Excel to Word

tigs, if I were you, I'd use DocVariables. First of all, do some research on
DocVariables. You'll see that you can see them in Word with Alt+F9. You
need to create named ranges in Excel. Then, urn this code (from Excel):

Sub PushToWord()

Dim objWord As New Word.Application
Dim doc As Word.Document
Dim bkmk As Word.Bookmark
sWdFileName = Application.GetOpenFilename(, , , , False)
Set doc = objWord.Documents.Open(sWdFileName)

objWord.activedocument.variables("BrokerFirstName" ).Value =
Range("BrokerFirstName").Value
objWord.activedocument.variables("BrokerLastName") .Value =
Range("BrokerLastName").Value

ActiveDocument.Fields.Update

objWord.Visible = True

End Sub

Of course your DocVariables and your named ranges will be different than
mine (they have to be the same in Word and in Excel), but anyway, that will
get you going.



--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"joel" wrote:


See if this helps. The code you posted was from 1999 which would of
been Office 1998. I changed the code to Office 2007 (12). Office 2002
is 10, and Office 2003 is (11). "bookmarkA" is a test bookmark that I
added to a document. You can change the name to anything you want to.


Dim appWD As Word.Application
' Create a new instance of Word & make it visible
Set appWD = CreateObject("Word.Application.12")
appWD.Visible = True
FName = "c:\temp\test.doc"
Set mydoc = appWD.Documents.Open(Filename:=FName)

With mydoc
.GoTo What:=wdGoToBookmark, Name:="bookmarkA"
End With


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?u=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=198453

http://www.thecodecage.com/forumz

.