473,387 Members | 1,572 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,387 software developers and data experts.

Import Access Information into Word

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.....code as follows (thanks to people for helping me with this bit of code a few days ago!!!)

Set appExcel = CreateObject("Excel.Application")

With appExcel
.UserControl = True
Set wkbWorkBook = .workbooks.Open(TemplatePathAssystem)
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("Word.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 2261
FishVal
2,653 Expert 2GB
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.....code as follows (thanks to people for helping me with this bit of code a few days ago!!!)

Set appExcel = CreateObject("Excel.Application")

With appExcel
.UserControl = True
Set wkbWorkBook = .workbooks.Open(TemplatePathAssystem)
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("Word.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
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
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...
4
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
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...
1
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...
2
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...
1
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...
4
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...
4
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...
2
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...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.