Getting a Word doc into Access (1 Viewer)

jpl458

Well-known member
Local time
Today, 08:01
Joined
Mar 30, 2012
Messages
1,038
My version of Alberts code that JDraw linked to is a bit more complicated than Alberts original code.
Alberts Original code can be found here . . . http://www.kallal.ca/msaccess/msaccess.html (scroll down to Super easy word merge)

I'm assuming you want to take some data from your database and insert it into a form letter using word.
Alberts code has a lot of different options and is well documented. I'd suggest you download it and read through his comments.
It lives up to its name "Super Easy" word merge.
I set it up but it's for a 32 bit machine, and I have a 64 bit rig. I read his stuff and filed it away. I got a message telling me what to do, so I'll give it a try. But, what I basically want to do is to move data from a list box or a query that updates the corresponding field that are bookmarked in a prewritten document. I would like to do that via vba, if possible. It's just one line of data in ACCESS, with name, addr, etc. and put those fields into a particular, single document. No contact lists. No merge. Just move data from here to there.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 11:01
Joined
Feb 19, 2002
Messages
43,295
Except that it is a merge if you use mail merge. Otherwise, it is OLE automation. Using OLE automation, you have a bunch of code to open the word document (always save the master as a template for safety). When you open the .dot file, it automatically copies the template and opens a copy as a regular .doc/.docx. Then you just poke each bookmark so it is one line of code for each bookmark you are filling. Save the file as a word doc or PDF.. Then print it or email it and close it. If you are not doing this from a form that is already posititoned on a record, then you also have to open a recordset.

The code in my sample assumes a batch job so it opens a recordset and prints a document for each record in the recordset. There's probably less than 20 lines of code that are relevant to your situation plus the poke for each bookmark.
 

moke123

AWF VIP
Local time
Today, 11:01
Joined
Jan 11, 2013
Messages
3,920
I set it up but it's for a 32 bit machine, and I have a 64 bit rig.
Machine bitness is 64 but what is your access bitness?
 

jpl458

Well-known member
Local time
Today, 08:01
Joined
Mar 30, 2012
Messages
1,038
Except that it is a merge if you use mail merge. Otherwise, it is OLE automation. Using OLE automation, you have a bunch of code to open the word document (always save the master as a template for safety). When you open the .dot file, it automatically copies the template and opens a copy as a regular .doc/.docx. Then you just poke each bookmark so it is one line of code for each bookmark you are filling. Save the file as a word doc or PDF.. Then print it or email it and close it. If you are not doing this from a form that is already posititoned on a record, then you also have to open a recordset.

The code in my sample assumes a batch job so it opens a recordset and prints a document for each record in the recordset. There's probably less than 20 lines of code that are relevant to your situation plus the poke for each bookmark.
I have no experience with OLE automation, but reading what you say that is what I need to learn. As I remember you have an example in the stuff you sent.
Machine bitness is 64 but what is your access bitness?
64 as well, I just checked. I am synced in the business of bitness! I hope that makes things easier.

Microsoft® Word for Microsoft 365 MSO (Version 2209 Build 16.0.15629.20200) 64-bit
 
Last edited:

jpl458

Well-known member
Local time
Today, 08:01
Joined
Mar 30, 2012
Messages
1,038
Is it because its easier to convert 32 bit ACCESS to 64 bit, or that 32 bit runs on both?
 

moke123

AWF VIP
Local time
Today, 11:01
Joined
Jan 11, 2013
Messages
3,920
Cant use older code on 64 bit access.

Does Pats code run on 64Bit access?
 

jpl458

Well-known member
Local time
Today, 08:01
Joined
Mar 30, 2012
Messages
1,038
Cant use older code on 64 bit access.

Does Pats code run on 64Bit access?
It opens (SampleWordAutomation.accdb) and it appears to work. When I clicked Preview Letter, the letter open behind ACCESS, but I got this error:

1667237478576.png

But it seemed to be working other wise. I don't know what that error means, but I found this:

this error is caused by some of the built-in protection in newer versions of office. to clear protected view from your report template, navigate to where you saved the template using windows explorer, and double-click to open it. then click on the enable editing button in the upper-right hand corner of the document.

Image

also have a look at:

https://support.microsoft.com/en-us/kb/264743

Does all this mean I should get Office 32bit?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 11:01
Joined
Feb 19, 2002
Messages
43,295
Does Pats code run on 64Bit access?
My code does not use API's so it should.

If you've been cursed with the latest "security" update, you have to figure out how to trust downloaded documents.
 

jpl458

Well-known member
Local time
Today, 08:01
Joined
Mar 30, 2012
Messages
1,038
My code does not use API's so it should.

If you've been cursed with the latest "security" update, you have to figure out how to trust downloaded documents.
I am creating the app on a 64 bit machine, but there may be some users that have 32 bit rigs. I checked with Microsoft and I can convert my Office 365 to a 32 bit version, but I have to uninstall the 64 bit version first. Then, is there an easy way to convert what I have to 32 bit. Being the rocket scientist that I am, I didn't think about that part when I started. Will be looking it up.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 11:01
Joined
Feb 19, 2002
Messages
43,295
Confusion reigns.

Any PC bought within the past 10 years is almost certainly a 64 bit machine. We are talking about HARDWARE. 64 bits is the size of a physical register and is the maximum length of an address.

Both 32 bit and 64 bit versions of Windows will run on 64-bit hardware. When running a 32 bit version of Windows, the high-order 16 bits of the registers are inoperative.

Both 32 bit and 64 bit versions of Office can run on 64-bit hardware BUT 64-bit versions of Office can only run if the 64-bit hardware is running a 64-bit version of Windows.

No 64-bit version of ANY software can run on a 32 -bit version of Windows.
No 64-bit version of ANY software can run on 32-bit hardware.

Are you following along?

You can create .accdb's with 64-bit versions of Office running with 64-bit versions of Office on 64-bit hardware. Those .accdb's will run on 32-bit versions of Office provided they don't use any 64-bit API's. HOWEVER, if you create .accde's from a 64-bit version of Office, they CANNOT run using 32-bit versions of Office under any condition.

The 64-bit versions of Word and Excel can support larger documents. HOWEVER, the 64-bit version of Access has no such advantage and it has disadvantages in that 32-bit versions of add-ins will not run in a 64-bit version of Office.

So, unless YOU, ACTUALLY need to work with humongous spreadsheets, YOU have NO NEED to run 64-bit Office. Therefore, the path of least resistance is for YOU to stick with 32 bit versions of Office on your 64-bit Windows on your 64-bit hardware.
 
Last edited:

jpl458

Well-known member
Local time
Today, 08:01
Joined
Mar 30, 2012
Messages
1,038
Thanks so much for that explanation. Now, before I put fingers to keyboard with what I have, on a 64 bit machine, when I covert to 32 bit Office, will I be able to convert what I have , or are we talking rewrite. I just checked the web and there are a lot of hits on how to convert 32 bit Office apps to 64 bit Office, but not the other way. However, I just watched a video by Richard Rost, who says that ACCESS will run on either 32 or 64 bit Office, if you don't have Active X controls or API calls, the app will run on both versions of Windows. The app I am creating uses neither, and is dirt simple. There is minimal data, and everything is self contained in the app, except for Word documents. Do you agree with that?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 11:01
Joined
Feb 19, 2002
Messages
43,295
As I said, unless you are using 64 bit API's - those are calls to the WINDOWS Application Programming Interface and have NOTHING to do with Office.

To see if you will have a problem, take your .accdb and open it on a PC that is running a 32 bit version of Office. If it works, you're fine. If it doesn't, you have stuff to fix before you can run the app on 32 bit versions of Office.
 

jpl458

Well-known member
Local time
Today, 08:01
Joined
Mar 30, 2012
Messages
1,038
As I said, unless you are using 64 bit API's - those are calls to the WINDOWS Application Programming Interface and have NOTHING to do with Office.

To see if you will have a problem, take your .accdb and open it on a PC that is running a 32 bit version of Office. If it works, you're fine. If it doesn't, you have stuff to fix before you can run the app on 32 bit versions of Office.
Thanks, Pat. I think I'm safe. In a lot of respects this is a dweeby little app. Not big, not fancy, but workable. You guys have helped me learn a lot.
BTW-I think the first Mainframe I wrote code for was an 8 bit machine. System 360 Model 30. It was the second one ever built, and put into the field by IBM.
 

Users who are viewing this thread

Top Bottom