access to word macro

fiesta_rich

New member
Local time
Today, 15:07
Joined
Apr 14, 2009
Messages
4
hi im setting up a database for a friend of mine who is setting his own business up and i want to transfer data from Access to Word to print an invoice off but i dont want to do it using mail merge I want to do it using VBA as I have done the whole database using VBA can anyone help me??

any help will be brill

rich
 
thanks for all the help people

got a problem
Private Sub Transfer_to_Word_Click()
Dim appWord As Word.Application
Dim doc As Word.Document

'Set appWord object variable to running instance of Word.

Set appWord = GetObject(, "Word.Application")

'Make sure you put in the correct path for the CustomerSlip.doc

Set doc = appWord.Documents.Open("F:\Richard's Uni Sept 08-09\BSADC\assignment 3\customeraccesstoword", , True)

doc.FormFields(1).Result = Me.CustomerCodeNo
doc.FormFields(2).Result = Me.CustomerName
doc.FormFields(3).Result = Me.CustomerAddress
doc.FormFields(4).Result = Me.CustomerPostcode
doc.FormFields(5).Result = Me.CustomerTelNo
doc.FormFields(6).Result = Me.CustomerContact
doc.FormFields(7).Result = Me.DeliveryNo
doc.FormFields(8).Result = Me.DriverCodeNo
doc.FormFields(9).Result = Me.CustomerCode
doc.FormFields(10).Result = Me.Pickupdate
doc.FormFields(11).Result = Me.ChargeCode
doc.FormFields(12).Result = Me.Packageweight
doc.FormFields(13).Result = Me.Loadsize
doc.FormFields(14).Result = Me.Distance
doc.FormFields(15).Result = Me.DelivaryCharge
doc.FormFields(16).Result = Me.Chargepermile





doc.Activate
Set doc = Nothing
Set appWord = Nothing

End Sub

when i try and click on the button to active the code this massage comes up
compile error:
user: defined type not defined

please help
 
can any ones help me please as i need to get this nailed as the deadline for me to hand over the system is on friday anyone??
 
what line is highlighted? there are two different ways i've done this, and one may work better for you than the other. give:

1) what line highlighted?
 
i got the same error.

compile error:
user: defined type not defined

this line is highlighted - appWord As Word.Application

please help.

imdl
 

Users who are viewing this thread

Back
Top Bottom