473,788 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Import Access Information into Word

7 New Member
Hi all,

I was hoping that someone could point me in the right direction or if nothing more, tell me that I am attempting the impossible (which I think I very well might be).

Quick overview - I have a form which shows and allows the modification of data. This all works well. I have created 2 buttons, one opens an Excel file and enters data into the template.....co de as follows (thanks to people for helping me with this bit of code a few days ago!!!)

Set appExcel = CreateObject("E xcel.Applicatio n")

With appExcel
.UserControl = True
Set wkbWorkBook = .workbooks.Open (TemplatePathAs system)
If Err <> 0 Then
MsgBox "Template file not found", vbOKOnly + vbCritical, "Error"
.Quit
GoTo ExitSub
End If
.Visible = True
End With

appExcel.Cells( 10, 4) = tbox_DRL
appExcel.Cells( 11, 4) = tbox_DocNo
appExcel.Cells( 12, 4) = tbox_Rev
appExcel.Cells( 13, 4) = getuser

This works happily but I have also been asked to enter similar data into a word document template. I use similar code to open the word template.

Set wdApp = CreateObject("W ord.Application ")

With wdApp

Set wdDoc = .Documents.Open (TemplatePath)

If Err.Number <> 0 Then 'Word isn't already running
MsgBox "Template file not found", vbOKOnly + vbCritical, "Error"
.Quit
GoTo ExitSub
End If
.Visible = True
End With

wdApp.Visible = True


The word template consists of a single table in which the data needs to be added.

Is it possible to direct the information into the correct cells on the word document?

Cheers

Phil
Jun 15 '07 #1
2 2278
FishVal
2,653 Recognized Expert Specialist
Hi all,

I was hoping that someone could point me in the right direction or if nothing more, tell me that I am attempting the impossible (which I think I very well might be).

Quick overview - I have a form which shows and allows the modification of data. This all works well. I have created 2 buttons, one opens an Excel file and enters data into the template.....co de as follows (thanks to people for helping me with this bit of code a few days ago!!!)

Set appExcel = CreateObject("E xcel.Applicatio n")

With appExcel
.UserControl = True
Set wkbWorkBook = .workbooks.Open (TemplatePathAs system)
If Err <> 0 Then
MsgBox "Template file not found", vbOKOnly + vbCritical, "Error"
.Quit
GoTo ExitSub
End If
.Visible = True
End With

appExcel.Cells( 10, 4) = tbox_DRL
appExcel.Cells( 11, 4) = tbox_DocNo
appExcel.Cells( 12, 4) = tbox_Rev
appExcel.Cells( 13, 4) = getuser

This works happily but I have also been asked to enter similar data into a word document template. I use similar code to open the word template.

Set wdApp = CreateObject("W ord.Application ")

With wdApp

Set wdDoc = .Documents.Open (TemplatePath)

If Err.Number <> 0 Then 'Word isn't already running
MsgBox "Template file not found", vbOKOnly + vbCritical, "Error"
.Quit
GoTo ExitSub
End If
.Visible = True
End With

wdApp.Visible = True


The word template consists of a single table in which the data needs to be added.

Is it possible to direct the information into the correct cells on the word document?

Cheers

Phil
Hi, Phil.

Your db never stops improving ;)

You can modify word document table in just a similar manner.

Expand|Select|Wrap|Line Numbers
  1.  
  2. With wdDoc.Tables(1)
  3. .Cell(10, 4).Range = tbox_DRL
  4. '...........................
  5. End With
  6.  
  7.  
I strongly recommend you use Object Browser in VBA window. This will help you to familiarize with application object model.

Good luck.
Jun 15 '07 #2
PhilOwens
7 New Member
Hi, Phil.

Your db never stops improving ;)

You can modify word document table in just a similar manner.

Expand|Select|Wrap|Line Numbers
  1.  
  2. With wdDoc.Tables(1)
  3. .Cell(10, 4).Range = tbox_DRL
  4. '...........................
  5. End With
  6.  
  7.  
I strongly recommend you use Object Browser in VBA window. This will help you to familiarize with application object model.

Good luck.
Hi FishVal,

If i get a payrise out of this database I do believe that I owe you a percentage cut :p

Works a treat. Always slightly annoying that all I needed to know was a few little lines of code and everything falls into place.

Thank you greatly for your help!

Phil
Jun 15 '07 #3

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

Similar topics

6
3713
by: Ecohouse | last post by:
I have a computer with XP on it. I loaded Office 97 first because I needed Access 97 for some work. I then loaded Office 2000. Everything seemed to be running fine. But I have come across a few problems. 1) I have hyperlinks in some tables and when I try to access the hyperlinks I get an error message "An unexpected error has occurred. 2) I've been trying to do some automation through Access for MS Word using VBA code. I've been...
4
1445
by: ray | last post by:
I am trying to use a word doc in access and am trying to create a database around this preconfigured form. pleas help
8
3538
by: Mike MacSween | last post by:
tblCourses one to many to tblEvents. A course may have an intro workshop (a type of event), a mid course workshop, a final exam. Or any combination. Or something different in the future. At the moment the printed output is usually going to Word. It's turning into an unholy mess, because I'm having to prepare umpteen different Word templates, and the queries that drive them, depending on what events a course has.
1
4026
by: David Berry | last post by:
Hi All. I'm looking for any help or sample code that can show me how to make a file import wizard in ASP.NET (VB preferred) like the one that MS Access uses. I'm working on a web site where the user has the ability to upload a file (.txt or .csv). The data in the file may be comma delaminated, tab delaminated, fixed width etc (we don't know). What I'd like to create is something like MS Access uses to import an Excel file into the...
2
4084
by: a.crowley | last post by:
I have a large set of Word documents that I wish to catalogue in an Access database. Each document has a set of file properties populated (title, subject, author, keywords, comments ect), so I'd like to import those into an Access table for processing. I've written VBS macros in the past to import data from Excel sheets into Access tables, but the same functionality does not appear to be available for Word. Any clues or sample code...
1
2709
by: rick m | last post by:
We have an access DB that 2 input people use to tracking incoming patients. There is a form for them to do this but they find it confusing to use (it's plainly laid out, no one else complains about it). Management has decided that they want me to link 15 of our templates so when a template is opened and text entered into one of the text fields it will automatically be entered into the database. First of all, is this possible? ...
4
12443
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is this: can Access create the document and place it as an OLE object to the relevant table? Any help is greatly appreciated. Ricky
4
2199
by: acc2ess | last post by:
Hello, My problem is that I receive different Word Documents as attachments and I need to get its data into the corresponding tables in access. I have used Text Form Fields in Word Document and could save it in text format and imported it in ms access, but this way takes long time.
2
4951
by: mburns | last post by:
Hello all- I was wondering if it is possible to link an Access query or table to a Word document and pull specific information into Word by manually entering a unique identifier, which would then pull all related fields from Access to the Word document. My goal is to develop a Word template that pulls certain fields from an Access query or table. For example, some of the fields I would like to pull from Access are etc..... But I would...
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10113
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5402
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4074
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2896
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.