PDA

View Full Version : select table from table collection in word



jon_w
07-01-2011, 02:32 AM
Hi,

I'm able to search and select a table in word using VBA, but the problem is the functions are slightly different in access, which is where i want to run the code:

Sub Copy()

Dim tbl4 As Word.Table
Dim doc As Word.Document

Set tbl4 = Selection.Document.Tables(4)
tbl4.Range.Copy

End Sub

runs prefectly in word, but i cannot use the selection function in access. Due to this being one of many stages of an access process, how can i get this same function to be done in access?

thanks
jon

Frosty
07-01-2011, 09:53 AM
This is potentially a much more complicated question than what you're asking, but I'm just going to give the simple response for now:

You may just need to indicate that you're talking about the Word.Application.Selection or Word.Selection.

macropod
07-01-2011, 08:08 PM
Perhaps something along the lines of:
Sub Copy()
Dim doc As Word.Document
set doc = 'Some document
doc.Tables(4).Range.Copy
End Sub

jon_w
07-04-2011, 02:49 AM
turns out I needed to select word from the library.
thanks