473,378 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

i am needing help with a command button that opens a word.docx?

i am using access 2010 and needing it to open a word.docx so that the user can just add an address to it and be done. i have already created the template word.docx just need help linking the two together with a command button.
haven't done code in a very long time and cant remember how to.
Jan 9 '16 #1
8 1054
zmbd
5,501 Expert Mod 4TB
There are a few ways to do this...

However, I think you'll end up with a modification of:

home > topics > microsoft access / vba > insights > application automation


Of course, for early binding (as shown in the two examples) you would set the library reference for MS Word instead of Outlook or Excel ;-)
Once the code is written you can slightly alter it to use late binding to help bullet proof the code once you have things working correctly.

Use the OpenDocuments Method of the Word object once created to open the document.

While you have it open, you can also transfer information from the database to bookmarked fields in the document.

As you mention that you have already done this in the past, let us know if you need more detailed help with this project.

-Z
Jan 9 '16 #2
NeoPa
32,556 Expert Mod 16PB
Another option should also be possible of using Shell() with just the name of the document. Assuming the PC is set to open Word for .DOCX files.
Jan 9 '16 #3
zmbd
5,501 Expert Mod 4TB
For some reason I always seem forget about the shell()... IDKW
:)

In this case, I was thinking about being able to push the currently user-entered address from the database.
> That's my story and I'm sticking to it! };-)
(chuckle)
Jan 9 '16 #4
NeoPa
32,556 Expert Mod 16PB
There are usually many ways to crack a nut ;-)
Jan 10 '16 #5
mbizup
80 64KB
A third nutcracker - behaves like double-clicking the file in it's folder if the application is on the computer (like the Shell command):

Expand|Select|Wrap|Line Numbers
  1. Application.FollowHyperlink "C:\Path\To\Your\File.anyextension"
Jan 10 '16 #6
NeoPa
32,556 Expert Mod 16PB
MBizup:
A third nutcracker
Third and best. It's what I should have suggested. The easiest and most straightforward approach.
Jan 10 '16 #7
zmbd
5,501 Expert Mod 4TB
Just keep in mind, how many times have we seen file-associations broken? :)

Even with that, mbizup suggestion is the easiest to implement!
Jan 10 '16 #8
NeoPa
32,556 Expert Mod 16PB
Even if it were broken the solution would be to fix it rather than to change the approach to this question IMO. The Shell() approach would suffer from the same issue if it raised its head.
Jan 10 '16 #9

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

Similar topics

0
by: gzimmer | last post by:
Every time I try to use the command button wizard (choosing any function) I get the following error message: Method "Module' of object'_Form_Opening Page' failed just as I push the "finish"...
4
by: John Smith | last post by:
I have a continuous form. there is a command button with the following code for the OnClick event: DoCmd.OpenForm "frmPlants", , , "PlantsID =" & Me!PlantsID I click the button and frmPlants...
3
by: afr0ninja | last post by:
Hello! I'm currently working on a form that has several input fields and a subform. What I'm trying to accomplish is that when I first open the form I'd like to have the input fields displayed...
8
FyrJammer
by: FyrJammer | last post by:
I apologize if there is already a discussion about this, but I don't have a lot of time looking for it. I need to create a command button that opens explorer to search for images to add / put into...
15
by: BaneMajik | last post by:
I am working with an Access 2003 inventory database. When a piece of equipment goes bad we junk it and delete it from the database. We have been copying the record to an excel form for storage just...
16
by: Steve | last post by:
I am working on a database that has a main menu, many sub-menus and some sub-sub-menus. They are all forms that have numerous command buttons on them to open forms and reports in the database. The...
1
by: alnino | last post by:
Hi, On a form I have a command button that allows a user to browse for a file (PDF, Word, etc…). This command button then stores a hyperlink to the file within an associated txtfield in the table....
3
by: extrym | last post by:
I have 2 forms, "Staff" and "Security" (without the ""'s). The Staff form has the following fields: staff_ID staff_name staff_number staff_DOB priority The Security form contains the...
3
by: ObiBenKenobi | last post by:
Hi there, I would like to know how to create an event procedure for a command button that uses the text of a textbox to go to a specified website. Example: User types "google" in a textbox,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.