By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,689 Members | 1,759 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,689 IT Pros & Developers. It's quick & easy.

View Word 2007 doc on Access 2007 form

P: 69
Basic question:
Does anyone know how to go about adding a control to an Access 2007 form that will allow viewing a Word 2007 document?

Reason for asking:
My office is about to receive 100+/- Word 2007 documents that contain data that needs to be imported into various fields of an Access 2007 table. To facilitate the import process, I was thinking of creating a form in Access that would have a Word control (or "window") at the bottom of the form that allows the me to view/preview the Word document. I would then place other "standard" Access controls on the top half of the form that would be bound to my Access table. This way I can use the Word "window" at the bottom of the form to scroll through the document, find the information I want, and then copy/paste the information into the bound controls at the top of the form.

Problem is, I don't know what control to use for my Word "window". I don't see anything suitable in the list of available Active X components.

What I've tried so far:
I already know how to use code to create a new Word object (which launches an instance of Word) and manipulate the Word document. But this doesn't really help me because the Word documents I will receive are coming from various agencies and individuals who will each, I'm sure, edit the document to their liking. Therefore, each document will be unique enough that I can't automate the import process. I need a visual control I can put on a Access form to allow me to see the document and determine where the information is that I want. Kind of like the preview feature in Outlook 2007 that displays Word attachments on the email form.

Of course I could always open the Word and Access applications side by side on my computer and copy/paste the data that I need. But I was hoping to find a more efficient approach since I have so many Word documents to import. At first this seemed like it should be easy to do. But after reading my own post, maybe this is harder than I realized.

Thanks for any help you can offer!
Jul 7 '09 #1
Share this Question
Share on Google+
5 Replies


100+
P: 675
I do similar things from email. The simple answer is to either open the 2 applications side-by-side (easier now with "wide-screen" monitors, or copy-paste the word document into your workspace window.

If you copy the text into workspace, you can then 'select' text and using the lostfocus event, save the highlighted text to a variable. When you select a field in your 'upper' space, it could be automatically filled with the saved(selected) text, saving much copy-paste cntl-C ... cntl-V.
Jul 7 '09 #2

P: 69
OldBirdman:

First, thanks for taking the time to read and respond to my post.

Second, when you say "workspace window", what kind of control do you have in mind? A regular Access textbox or something else?

The data I want from the Word 2007 files exists in "tables" (i.e. Word tables, not Access tables). If I try to load this information into a regular textbox, all of the table formating (such as the column alignment and background shading) is lost. The information in the table gets smashed together and it's almost impossible to find the information I need. Therefore, a regular textbox wont fit the bill.

I figured there had to be a component/control exposed by Word 2007 already on my computer that I could put on my Access form that would be able to handle all of the Word table formating. Just like there is a "Microsoft Office Spreadsheet 10.0" ActiveX control exposed by Excel to handle spreadsheets, I was looking for something similar for Word. Unfortunately, I don't know where the equivalent Word component is, or what it's called. I thought someone else might be able to tell me.

Perhaps one doesn't exist. However, as I noted in my previous post, Outlook 2007 has a preview feature for Word 2007 files just like I want for my Access form. I just don't know how to crawl inside Outlook to figure out what it's doing so I can replicate it in Access.

Again, any help is greatly appreciated.


@OldBirdman
Jul 8 '09 #3

100+
P: 675
Yes, I create an UnBound TextBox on my form. A textbox can hold 4096 characters, I think, and that takes care of most email that I process.
I use the MouseUp Event to do this in the workspace.
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtWorkspace_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2.     If txtWorkspace.SelLength = 0 Then
  3.         strHold = ""
  4.     Else
  5.         strHold = txtWorkspace.SelText
  6.     End If
  7. End Sub
For each possible target location, I have the following:
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtTarget_GotFocus()
  2.     If strHold <> "" Then
  3.         txtTarget = strHold
  4.         strHold = ""    'Remove this if you want to paste same data into multiple locations
  5.     End If
  6. End Sub
To consider if going this route -
1) Command buttons to a)Clear txtWorkspace, b) Paste to txtWorkspace, c) Clear strHold which is done by clicking txtWorkspace without selecting anything
2) Is the autoClear of strHold desired (Line 4 of GotFocus code, above)
3) Automate selection of target textboxes
3a) Have a list of textboxes to fill from document
3b) On each MouseUp, the next textbox would be filled, without having to click it

I pick through email with these methods quite quickly. The code shown works well where all desired information is not supplied, and some fields may be left blank. If I knew that ALL the data would be available, I would code with 3a, 3b, which isn't much more difficult to do.

I have Access2003, and for your data it will all get "smashed" using my methods. I have read that Access2007 can retain RichText formatting, and so it might be available to you. Whether it preserves the tables well enough, I don't know.

Can you copy the table from Word to Excel, and then import to an Access table? Just a thought.
Jul 8 '09 #4

P: 69
OldBirdman:

Again, thanks for your response. I appreciate the time and thought you put into it.

Unfortunately, a textbox just isn't going to work. I did however hit upon what I think will be the solution. It's a bound object frame control (a standard Access control) that I just done bind to a field.

With this control I can temporarily embed my Microsoft Word document into the control and view it just like I was in Microsoft Word. I've still got a view bugs to work out with document navigation and text selection, but this seems to be just what I need.

In addition, the code you provided for the MouseUp and GotFocus events will help streamline the copy/paste operation.

Thanks again for your help.

Regards,
sphinney

@OldBirdman
Jul 13 '09 #5

100+
P: 675
Glad I could help, even though I didn't know exactly how to solve your problem.
Jul 13 '09 #6

Post your reply

Sign in to post your reply or Sign up for a free account.