将Access 2003文本字段导出到Word。 [英] Exporting Access 2003 text fields into Word.

查看:60
本文介绍了将Access 2003文本字段导出到Word。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨伙计们;

嘿哇!第一篇文章!希望它结出硕果......无论如何,我从三月开始为自己工作的公司编写事件/联系人管理数据库,从而自学了Access。这是相当简单的,它只是记录我们的客户在其他thihgs中的细节。旧的Lotus DB它(据说是!)取代有一个方便的功能,到目前为止我没有运气在Access中复制。它的工作原理如下:


1.用户浏览客户联系人记录,其中包含作为单独字段存储的所有个人联系人数据。
<然后,用户可以单击联系表单上的一个方便按钮,该按钮将自动捕获相关字段中的文本,整理它,并将它们作为地址块拼接到自动打开的文本的顶部。文件。


3.用户可以像往常一样在地址下面的联系人处写一封信。当打印信件时,地址块将位于通过窗口信封可见的正确位置。


这就是真的。我进行了长时间的搜索,发现了很多方法可以从Access导出到Word,或者从Access导入到Word,但是没有一种方法是如此简单或直接。我知道这一定有可能,但有人知道怎么做?迄今为止我能做的最好的事情就是在运行查询的表单上插入一个按钮,并在弹出的表格中显示我选择的字段,但就是这样。


我不是Access专家,我不知道如何编码,所以任何回复都以简单,只需启动C ++和xyz ......开头。可能会让我流泪!我对宏和查询以及微软软件包一般都很好,所以如果有人有任何想法,我很乐意听到它们。


谢谢大家!

Hi folks;
Hey wow! First post! Hope it bears fruit... Anyway, I''ve been teaching myself Access since March by writing an event/contact management database for the firm I work for. It''s reasonably straightforward, it just records details on our clients among other thihgs. The old Lotus DB it (supposedly!) supercedes had a handy feature that I''ve so far had no luck in replicating in Access. It worked as follows:

1. The user browsed to a Client Contact record, which contained all of an individual person''s contact data stored as separate fields.

2. The user could then click a handy button on the Contact form that would automatically capture the text from the relevant fields, collate it, and plonk them as an address block into the top of an automatically opened text document.

3. The user could then type a letter to the contact below the address as usual. When the time came to print the letter the address block would be in just the right place to be visible through a windowed envelope.

That''s about it really. I''ve had a long search and found many ways to export from Access to Word, or import from to Word from Access, but none of them are so simple or straightforward. I know this must be possible somehow, but does anybody know how? The best I''ve been able to do so far is insert a button on the form that runs a query and displays the fields I picked in a table that pops up, but that''s it.

I''m not an Access pro and I don''t know how to code, so any replies starting with "Simple, just fire up C++ and xyz...." will probably leave me in tears! I''m fine with macros and queries and Microsoft packages in general, so if anyone has any ideas I''d love to hear them.

Thanks guys!

推荐答案


嗨伙计们;

哇哇!第一篇文章!希望它结出硕果......无论如何,我从三月开始为自己工作的公司编写事件/联系人管理数据库,从而自学了Access。这是相当简单的,它只是记录我们的客户在其他thihgs中的细节。旧的Lotus DB它(据说是!)取代有一个方便的功能,到目前为止我没有运气在Access中复制。它的工作原理如下:


1.用户浏览客户联系人记录,其中包含作为单独字段存储的所有个人联系人数据。
<然后,用户可以单击联系表单上的一个方便按钮,该按钮将自动捕获相关字段中的文本,整理它,并将它们作为地址块拼接到自动打开的文本的顶部。文件。


3.用户可以像往常一样在地址下面的联系人处写一封信。当打印信件时,地址块将位于通过窗口信封可见的正确位置。


这就是真的。我进行了长时间的搜索,发现了很多方法可以从Access导出到Word,或者从Access导入到Word,但是没有一种方法是如此简单或直接。我知道这一定有可能,但有人知道怎么做?迄今为止我能做的最好的事情就是在运行查询的表单上插入一个按钮,并在弹出的表格中显示我选择的字段,但就是这样。


我不是Access专家,我不知道如何编码,所以任何回复都以简单,只需启动C ++和xyz ......开头。可能会让我流泪!我对宏和查询以及一般的Microsoft软件包很好,所以如果有人有任何想法,我很乐意听到它们。


谢谢大家!
Hi folks;
Hey wow! First post! Hope it bears fruit... Anyway, I''ve been teaching myself Access since March by writing an event/contact management database for the firm I work for. It''s reasonably straightforward, it just records details on our clients among other thihgs. The old Lotus DB it (supposedly!) supercedes had a handy feature that I''ve so far had no luck in replicating in Access. It worked as follows:

1. The user browsed to a Client Contact record, which contained all of an individual person''s contact data stored as separate fields.

2. The user could then click a handy button on the Contact form that would automatically capture the text from the relevant fields, collate it, and plonk them as an address block into the top of an automatically opened text document.

3. The user could then type a letter to the contact below the address as usual. When the time came to print the letter the address block would be in just the right place to be visible through a windowed envelope.

That''s about it really. I''ve had a long search and found many ways to export from Access to Word, or import from to Word from Access, but none of them are so simple or straightforward. I know this must be possible somehow, but does anybody know how? The best I''ve been able to do so far is insert a button on the form that runs a query and displays the fields I picked in a table that pops up, but that''s it.

I''m not an Access pro and I don''t know how to code, so any replies starting with "Simple, just fire up C++ and xyz...." will probably leave me in tears! I''m fine with macros and queries and Microsoft packages in general, so if anyone has any ideas I''d love to hear them.

Thanks guys!



将您的搜索细化为称为邮件合并的内容。它不像旧学校的东西那样按钮......但它是可行的。


www.msdn.com(搜索Access邮件合并)将会让你知道它的全部意义。我觉得比我更容易打字或粘贴它更容易。

J


refine your search to something called a mail merge. it''s not quite so push button as the old school stuff...but it''s doable.

www.msdn.com (search for Access mail merge) that will give you an idea of what it''s all about. Easier than me trying to type or paste it all in I think.
J


感谢信息J,所有有用的东西。我打了另一个绊脚石!在搜索了大部分图表互联网以获得答案后,​​它仍然坚持下去。令人抓狂的是,我可以看到它与jut一些调整,但因为我不是真的理解 VB的内部工作原理我可以做的就是四处看看会发生什么。


到目前为止,我的Access窗体上的邮件合并按钮的Click事件附加了以下代码:


函数MergeIt()

Dim objWord As Word.Document


设置objWord = GetObject(" S:\ GRADUATIONS \知识管理数据库\ Mark 2 \mergedoc.doc",Word.Document)

''使Word可见。

objWord.Application.Visible = True


''将邮件合并数据源设置为当前数据库。

objWord.MailMerge.OpenDataSource _

名称:= CurrentDb.Name,_

LinkToSource:= True,_

Connection:=" TABLE tblContactDetails",_

SQLStatement:="选择firstname,lastname,jobtitle,department,address1,ad dress2,address3,city,lookupcounties,postcode,count from tblContactDetails WHERE Con​​tactID = [frmContactDet ails!contactID]"


''执行邮件合并。

objWord.MailMerge.Execute


结束函数


它或多或少是从MSDN文章中复制的,但有一些拖拽指向正确的文件。我认为问题出在我的SQL语句中。我找不到一种方法让它只选择当前表单上的地址详细信息而不是整个数据库。我不确定它是否允许我解决ContactID = [frmContactDetails!contactID]的问题。作为有效的WHERE语句。最初的MSDN文章有SQL语句SQLStatement:=" Select * from [table]",但它将表中的每条记录输出到Word,而这不是我需要的!


无论如何,如果有人有任何想法,我很乐意听到他们!


Hen
Thanks for the info J, all helpful stuff. I''ve hit another stumbling block though! After having trawled most of the charted Internet for an answer it''s still sticking. The maddening thing is that I can see it working with jut a few tweaks, but because I don''t really "understand" the inner workings of VB all I can do is poke around and see what happens.

So far I have the following code attached to the Click event of the Mail Merge button on my Access form:

Function MergeIt()
Dim objWord As Word.Document

Set objWord = GetObject("S:\GRADUATIONS\Knowledge Management Database\Mark 2\mergedoc.doc", "Word.Document")
'' Make Word visible.
objWord.Application.Visible = True

'' Set the mail merge data source as the current database.
objWord.MailMerge.OpenDataSource _
Name:=CurrentDb.Name, _
LinkToSource:=True, _
Connection:="TABLE tblContactDetails", _
SQLStatement:="Select firstname,lastname,jobtitle,department,address1,ad dress2,address3,city,lookupcounties,postcode,count ry from tblContactDetails WHERE ContactID=[frmContactDetails!contactID]"

'' Execute the mail merge.
objWord.MailMerge.Execute

End Function

It''s more or less copied from the MSDN article but with a few tugs to point it to the correct files. I think the problem is with my SQL statement. I can''t find a way to make it pick only the address details on the current form rather than the entire database. I''m not sure it''s allowing me to address "ContactID=[frmContactDetails!contactID]" as a valid WHERE statement. The original MSDN article had the SQL statement SQLStatement:="Select * from [table]", but that outputs every record in the table to Word and that''s not what I need!

Anyway, if anybody has any ideas I''d love to hear them!

Hen



感谢信息J,所有有用的东西。我打了另一个绊脚石!在搜索了大部分图表互联网以获得答案后,​​它仍然坚持下去。令人抓狂的是,我可以看到它与jut一些调整,但因为我不是真的理解 VB的内部工作原理我可以做的就是四处看看会发生什么。


到目前为止,我的Access窗体上的邮件合并按钮的Click事件附加了以下代码:


函数MergeIt()

Dim objWord As Word.Document


设置objWord = GetObject(" S:\ GRADUATIONS \知识管理数据库\ Mark 2 \mergedoc.doc",Word.Document)

''使Word可见。

objWord.Application.Visible = True


''将邮件合并数据源设置为当前数据库。

objWord.MailMerge.OpenDataSource _

名称:= CurrentDb.Name,_

LinkToSource:= True,_

Connection:=" TABLE tblContactDetails",_

SQLStatement:="选择firstname,lastname,jobtitle,department,address1,ad dress2,address3,city,lookupcounties,postcode,count from tblContactDetails WHERE Con​​tactID = [frmContactDet ails!contactID]"


''执行邮件合并。

objWord.MailMerge.Execute


结束函数


它或多或少是从MSDN文章中复制的,但有一些拖拽指向正确的文件。我认为问题出在我的SQL语句中。我找不到一种方法让它只选择当前表单上的地址详细信息而不是整个数据库。我不确定它是否允许我解决ContactID = [frmContactDetails!contactID]的问题。作为有效的WHERE语句。最初的MSDN文章有SQL语句SQLStatement:=" Select * from [table]",但它将表中的每条记录输出到Word,而这不是我需要的!


无论如何,如果有人有任何想法,我很乐意听到他们!


Hen
Thanks for the info J, all helpful stuff. I''ve hit another stumbling block though! After having trawled most of the charted Internet for an answer it''s still sticking. The maddening thing is that I can see it working with jut a few tweaks, but because I don''t really "understand" the inner workings of VB all I can do is poke around and see what happens.

So far I have the following code attached to the Click event of the Mail Merge button on my Access form:

Function MergeIt()
Dim objWord As Word.Document

Set objWord = GetObject("S:\GRADUATIONS\Knowledge Management Database\Mark 2\mergedoc.doc", "Word.Document")
'' Make Word visible.
objWord.Application.Visible = True

'' Set the mail merge data source as the current database.
objWord.MailMerge.OpenDataSource _
Name:=CurrentDb.Name, _
LinkToSource:=True, _
Connection:="TABLE tblContactDetails", _
SQLStatement:="Select firstname,lastname,jobtitle,department,address1,ad dress2,address3,city,lookupcounties,postcode,count ry from tblContactDetails WHERE ContactID=[frmContactDetails!contactID]"

'' Execute the mail merge.
objWord.MailMerge.Execute

End Function

It''s more or less copied from the MSDN article but with a few tugs to point it to the correct files. I think the problem is with my SQL statement. I can''t find a way to make it pick only the address details on the current form rather than the entire database. I''m not sure it''s allowing me to address "ContactID=[frmContactDetails!contactID]" as a valid WHERE statement. The original MSDN article had the SQL statement SQLStatement:="Select * from [table]", but that outputs every record in the table to Word and that''s not what I need!

Anyway, if anybody has any ideas I''d love to hear them!

Hen

''假设[ContactID]是一个数值:

''Assuming [ContactID] is a Numeric Value:

展开 | 选择 | Wrap | 行号


这篇关于将Access 2003文本字段导出到Word。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆