Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2005

Tip: Looking for answers? Try searching our database.

Select a frame in word with a macro in excel

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Trefor - 06 Oct 2005 10:51 GMT
I am trying to write a macro in Excel that will copy the text in a Word frame
to a cell in Excel. Can anyone give me some sample code?
Signature

Trefor

Ness - 06 Oct 2005 12:38 GMT
Trefor,
You need to reference ms forms 2.0 object library and and microsoft Word
object library for this to work:-

Option Explicit

Dim objClipBoard(1) As New DataObject
Dim objWd As Word.Application
Dim objWdDoc As Word.Document

Sub test()

Set objWd = New Word.Application
objWd.Visible = True
Set objWdDoc = objWd.Documents.Open("c:\test.doc")

objWdDoc.Frames(1).Select 'index of 1 being first frame in document
objWdDoc.Frames(1).Range.Select

Dim strFrameContents As String
strFrameContents = objWd.Selection
objClipBoard(0).SetText strFrameContents
objClipBoard(0).PutInClipboard

objClipBoard(1).GetFromClipboard
Range("a1").Select
ActiveCell.Formula = objClipBoard(1).GetText

Set objWd = Nothing
Set objWdDoc = Nothing
End
End Sub

> I am trying to write a macro in Excel that will copy the text in a Word frame
> to a cell in Excel. Can anyone give me some sample code?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.