Im currently tinkering with a new database for managing our calls and quotations and I was wondering if you could help me out.
Im trying to prevent doubling the workload as we currently type an enquiry out and then we type a quotation I want to type out an enquiry and then click a button to copy all the information into a word template.
I have been following this online procedure;
http://blogs.techrepublic.com.com/msoffice/?p=164
The code I have used is below and I have uploaded the file aswell so that if anyone can help me out and take alook?
http://files-upload.com/files/495888/New Database.zip
Im currently receiving the following error!
"The expression On Click you entered as the event property setting produced the following error: Invalid outside procedure"
This is my code;
Private Sub cmdPrint_Click()
'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:\Documents and Settings\Administrator\Desktop\New Database\quotations.dot", , True)
With doc
.FormFields("fldCompanyName").Result = Me!CompanyName
.FormFields("fldReference").Result = Me!Reference
.FormFields("fldAddress1").Result = Me!Address1
.FormFields("fldPostalTown").Result = Me!PostalTown
.FormFields("fldCounty").Result = Me!COUNTY
.FormFields("fldPostCode").Result = Me!PostCode
.FormFields("fldContactName").Result = Me!ContactName
.FormFields("fldProjectTitle").Result = Me!ProjectTitle
.FormFields("fldDealtWithBy").Result = Me!DealtWithBy
.Visible = True
.Activate
End With
Set doc = Nothing
Set appWord = Nothing
Exit Sub
errHandler:
MsgBox Err.Number & ": " & Err.Description
End Sub
If anyone could help me it would be greatly appreciated
Im trying to prevent doubling the workload as we currently type an enquiry out and then we type a quotation I want to type out an enquiry and then click a button to copy all the information into a word template.
I have been following this online procedure;
http://blogs.techrepublic.com.com/msoffice/?p=164
The code I have used is below and I have uploaded the file aswell so that if anyone can help me out and take alook?
http://files-upload.com/files/495888/New Database.zip
Im currently receiving the following error!
"The expression On Click you entered as the event property setting produced the following error: Invalid outside procedure"
This is my code;
Private Sub cmdPrint_Click()
'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:\Documents and Settings\Administrator\Desktop\New Database\quotations.dot", , True)
With doc
.FormFields("fldCompanyName").Result = Me!CompanyName
.FormFields("fldReference").Result = Me!Reference
.FormFields("fldAddress1").Result = Me!Address1
.FormFields("fldPostalTown").Result = Me!PostalTown
.FormFields("fldCounty").Result = Me!COUNTY
.FormFields("fldPostCode").Result = Me!PostCode
.FormFields("fldContactName").Result = Me!ContactName
.FormFields("fldProjectTitle").Result = Me!ProjectTitle
.FormFields("fldDealtWithBy").Result = Me!DealtWithBy
.Visible = True
.Activate
End With
Set doc = Nothing
Set appWord = Nothing
Exit Sub
errHandler:
MsgBox Err.Number & ": " & Err.Description
End Sub
If anyone could help me it would be greatly appreciated