Unanswered: HELP, I have a problem, n my work is due in on friday
I need to submit my coursework in on friday, I have made a mail merge , but I want to create a button on a form that will automatically run the document, so is it possible for somebody to show what script/code i need to use in a module. Please.
Did you ever get a solution for this? I am having the same problem myself. What I did instead was to create a command button with a hyperlink to that document and let them select what data they want to see using a check box and then use the onClick event with command button. It works just as good but having them click only one button would be better.
I have the word document set up for mail merge and the record source assigned so what I want it to do is on my form frmCreateLetters, have a command button, and when clicked it opens the word document and updates the data in a table I have details in such as name address etc. What I have in my code is:
1- its run a query to update the table temp table
2- Open the word document and display the updated names and addresses.
What happens is that the mail merge document wont update with new values.
Dim appWord As Object
Set appWord = CreateObject("Word.Application")
appWord.Visible = True
Dim objDoc As Object
Set objDoc = appWord.Documents.Open("C:\Databases\Access Databases\MergeLetters")
The query 'qryPrintLetter' updates value in in a table called 'TempMembers' which the document mail merges with. When you click the command button to perform this code it opens the word document but the names and address dont appear. It also doesnt ask you if you want to perform the mail merge SQL query.
Yes - I can see the point about not using Dim x As New y. To be honest - that is mainly lazyness - I knew the object is not actually initialised until it is actually used (unlike .Net) but hadn't followed that through to the debugging issue that you then don't know if it is the method or the instantiation that has gone wrong. I will change my habbits there.
I always use early binding with no problems (XP -> 2003 clients). To be fair I didn't cover the gotcha - make sure you are referencing the oldest (including service packs) version of the app that any of your clients will be using - that in itself might mean an install. What the article doesn't mention is that late binding requires a lookup of the method DISPID (rather than the VTable that early binding does at compile time) which can have performance implications (especially in loops). It also allows you to trap lots more errors at design time.
I use New over CreateObject as the latter is no longer supported in .NET - I just don't want to confuse myself. I must confess my COM book implied that they are different ways of calling the same process whereas the article suggests otherwise.
Anyway - there are pros and cons to both. You were correct to pull me up for suggesting that early binding is the "correct" way though