Forum Home
Press F1
 
Thread ID: 50639 2004-10-27 22:11:00 MS Word: how do I embed an object inside a text box Tinakarori (2162) Press F1
Post ID Timestamp Content User
285165 2004-10-27 22:11:00 I want to embed an Excel workbook *inside* a Word text box, but have been unsuccessful so far despite following the Help instructions. (Don't ask why: the objectives would only interest management accountants...... all right, I'll explain: it's part of setting up a semi-automated monthly performance reporting format)

I can simply embed the required section/area of the workbook in the ordinary body of the document, no problem, but it doesn't work when I try to do the same thing within a text box.

The reason for placing the Excel object inside a text box, rather than in the body of the document, is to facilitate users' movement from place to place in the format, i.e. the bits they should review and update. If these sections are each located inside a text box, I can include "Move to next Box" and other helpful document navigation buttons on the custom toolbar I have built for the format.
Tinakarori (2162)
285166 2004-10-27 22:21:00 Works for me in Excel 2003.
What version are you using?
godfather (25)
285167 2004-10-27 23:06:00 Theres TextBoxes and TextBoxes. From which toolbar did you draw it? If you use a textbox object from the drawing toolbar you can do this but not from a TextBox control from either the Visual Basic or Control Toolbox toolbars.

However, I would just use a bookmark for each location and a button to go backwards and forwards to the next bookmark.
parry (27)
285168 2004-10-28 00:23:00 Theres probably easier ways to do this but I dont know the Word object model well enough.

1. open the VBE (Alt+F11)
2. Insert a Module (Insert|Module)
3. Paste the code below in the right hand window
4. Close the VBE (Alt+Q)

Create two buttons on your toolbar to go backwards and forwards between bookmarks - eg one called Next Bookmark and the other one called Previous Bookmark.

Assign the NextBkMark macro to the Next Bookmark button and the PrevBkMark macro to the Previous Bookmark button.

Public BkmkArr
Public CurBkmk As String


Sub NextBkMark()
Dim TotalBkmks, i As Integer

TotalBkmks = ActiveDocument.Bookmarks.Count

If CurBkmk = "" Then
ActiveDocument.Bookmarks(1).Select
CurBkmk = ActiveDocument.Bookmarks(1).Name
Exit Sub
End If

For Each bkmk In ActiveDocument.Bookmarks
i = i + 1
If bkmk.Name = CurBkmk Then Exit For
Next bkmk

If i + 1 > TotalBkmks Then
MsgBox "You're at the last bookmark!"
Else
CurBkmk = ActiveDocument.Bookmarks(i + 1).Name
ActiveDocument.Bookmarks(i + 1).Select
End If

End Sub

Sub PrevBkMark()
Dim TotalBkmks, i As Integer

TotalBkmks = ActiveDocument.Bookmarks.Count

If CurBkmk = "" Then
ActiveDocument.Bookmarks(1).Select
CurBkmk = ActiveDocument.Bookmarks(1).Name
Exit Sub
End If

For Each bkmk In ActiveDocument.Bookmarks
i = i + 1
If bkmk.Name = CurBkmk Then Exit For
Next bkmk

If i - 1 < 1 Then
MsgBox "You're at the first bookmark!"
Else
CurBkmk = ActiveDocument.Bookmarks(i - 1).Name
ActiveDocument.Bookmarks(i - 1).Select
End If

End Sub
parry (27)
1