Hi,
I've found a tutorial that shows you how to fill in Word documents with values from Access - 'Print customer slip for current customer.
-
Dim appWord As Word.Application
-
Dim doc As Word.Document
-
'Avoid error 429, when Word isn't open.
-
On Error Resume Next
-
Err.Clear
-
'Set appWord object variable to running instance of Word.
-
Set appWord = GetObject(, "Word.Application")
-
If Err.Number <> 0 Then
-
'If Word isn't open, create a new instance of Word.
-
Set appWord = New Word.Application
-
End If
-
Set doc = appWord.Documents.Open("C:\BLANK INSTRUCTION_TEMPLATE.docx", , True)
-
With doc
-
.FormFields("fldCustomerID").Result = Me!CustomerID
-
.FormFields("fldCompanyName").Result = Me!CompanyName
-
.FormFields("fldContactName").Result = Me!ContactName
-
.FormFields("fldContactTitle").Result = Me!ContactTitle
-
.FormFields("fldAddress").Result = Me!Address
-
.FormFields("fldCity").Result = Me!City
-
.FormFields("fldRegion").Result = Me!Region
-
.FormFields("fldPostalCode").Result = Me!PostalCode
-
.FormFields("fldCountry").Result = Me!Country
-
.FormFields("fldPhone").Result = Me!Phone
-
.FormFields("fldFax").Result = Me!Fax
-
.Visible = True
-
.Activate
-
End With
-
Set doc = Nothing
-
Set appWord = Nothing
-
Exit Sub
-
errHandler:
-
MsgBox Err.Number & ": " & Err.Description
I am using Office 2007 and it doesn't seem to be working. I can see that WINWORD.exe is open in my Task Manager but the actual word document is not launching.
Does anybody know how to modify the above code to make it work with Office 2007.
Thanks,
Marat
Jul 11 '08
10 9241
The bookmark property is the name of the Form Field in Office 2003, but I can't see that same property in Office 2007.
When I add the Form Fields to my Word document, I can set their Title, but I'm not sure if that is their name that I would use in .FormFields("du eDateTem").Resu lt = DateDueToClient .Value.
I know there is a comment on the tutorial: "Hi is the office 2007 version avaliable yet? If so where can i find it please? "
So I don't think I'm the only one having the problem with Office 2007.
I don't have word 2007, but the problem seems to be lack of documentation for word 2007 at this period in time. I looked, but could not find any solid info. Let's see if we can get one form field working.
Try replacing line 15 with lines 15a and 15b, then tell me what happens.
With doc
15. .FormFields("fl dCustomerID").R esult = Me!CustomerID
With doc
15a. .Bookmarks.Add Range:=Selectio n.Range, Name:= "fldCustome rID"
15b. Me!CustomerID = bookmarks("fldC ustomerID").ran ge
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Ronny Sigo |
last post by:
Hello all,
I am a newbie to access.
I try to pass data from a form into a new Word document
Below you see how far I got ... can anybody help ?
Private Sub btnMaakbrief_Click()
If lGoon = False Then
' Here I check some of the controls to see if they contain required
data, if not a msgbox is displayed
|
by: Otis Hunter |
last post by:
I have been given an Access Database which contains a table that has
an OLE object field that contains a Word document. That table contains
hundreds of records. I would like to find out how I can write a VB
script, to be executed either within Access or executed at the CMD
prompt, which will loop through all the records and open the document
object and save it to a Word document that I can access from Windows
Explorer. An additional info...
|
by: kelly.pearson |
last post by:
I had some access 97 reports that I used to publish to MS Word that
worked before we upgraded to Access 2K and Word 2K. Although there
were some minor discrepancies, I was able to tweak the access reports
and fix those problems.
After the upgrade to Office 2K, when I publish the report to MS Word a
..rtf document is created instead of a .doc document and it has many
problems. i.e., lines don't show up, words are missing, sentences are...
|
by: Niklas Uhlin |
last post by:
Someone please explain why Session_Start fires multiple times /
retains SessionID values between sessions, when you open an ASP.NET
page from MS Word. For details of the problem, see below:
1. Create a new C# ASP.NET web application named "demo" and modify
Session_Start in Global.asax.cs as follows:
protected void Session_Start(Object sender, EventArgs e)
{
Response.Write("Session_Start event fired at "+
|
by: Dave |
last post by:
Apologies for the newbie question. I have created a vb.net program for
my company that is designed to work with Word Templates (about forty of
them that we commonly use) that are selected by the user and populated
(with info from an Access database) at run-time, then saved as Word
documents. The program I have coded works fine -- it does what I need
it to do. But it has two problems: (1) it runs very slowly, and (2) it
does not seem to...
| |
by: ruomingxu via AccessMonster.com |
last post by:
I am new in this area. I want to use values in a Access database and pass
them to a word document. I tried this test code in a form of the Access
database but it didn't work (temp.doc is a word doc already stored in C:
drive):
Dim oX As Object
Set oX = CreateObject("C:\temp.doc")
oX.editreplace "<<FirstName>>", "Richard", 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0
oX.Application.Visible = True
Set oX = Nothing
|
by: MayBoy |
last post by:
Hi There
I am trying to use the Goto method of the Word ActiveX object. I am
trying to open a document and go to a named bookmark. If I use this
code in VB it works, so I'm sure the approach is possible, I just can't
get JavaScript to work with it.
Here is the code I am using, the error I get from IE is Object
Expected:
Hope someone can help! Any help would be much appreciated
|
by: babyangel43 |
last post by:
Hello, I have a query set up in Access. I run it monthly, changing
"date of test". I would like this query to be merged with a Word
document so that the cover letter is created in Word, the fields from
Access are automatically filled into the Word document. The query
could be anywhere from 0-5000 names, one cover letter per name. AND to
this cover letter for each applicant, there has to be attached a two
page document. How in the world can...
|
by: no8do |
last post by:
Hi there,
I am brand new in access and VBA programming and I am asking for your help. One of the fields in my db is of the OLE object data-type. I' ve written a vb script that is executed on a button's click on my form for openning an embedded word document, on which I can write text. The text is saved on the field as soon as I close the word document. For the record, the code that I use is the following:
A.Class = "Word.Document" ' Set...
|
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,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
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...
| |