Maybe I should use the term arguments rather than parameters.
Currently I have a working template that when users open it has an OCX
Desktop connection to a database which has a file number. With that number I
can then sql other database files and populate the new document.
What I'd like to do is streamline the process and call the template from a
workflow. Within that workflow task I have a file number which I would use to
sql other databases and populate the doc.
Is this possible?
Thanks,
Bryan
:
I'm not completely sure what you are driving at, but...
Set objWord = objWordApp.Documents.Add("TemplateName")
....I guess it's obvious that the only "variables" in there - are
- objWord
- the mechanism you are using to create the new document
- the template name, and by extension, anything that you can store in
that template that you can then reference using VBA.
In other words, if you want to access /different data/ depending on
which /template/ you base your document on, then what you probably need
to do is store the relevant connection information in your template. One
way to do that would be create Word Document variables in your template
that stored the information necessary to connect to a particular
database and retrieve information from it.
For example, suppose each template had two document variables as follows:
a. DSConnection, storing an OLE DB connection string that would let
you use ADO to open a particular SQL Server database
b. DSCommand, storing a SQL SELECT statement that would let you open
an ADO Recordset
then you could use
objWord.Variables("DSConnection")
to extract the connection string,
objWord.Variables("DSCommand")
to extract the SQL (or whatever) statement, and use ADO to get the data
you need.
That would mean that each /template/ could be used to open a different
data source. But if you need to do something different every time you
create a new document, it isn't clear where the data is that would make
you do thing "X" one time and thing "Y" the next - maybe you could try
to spell that out.
Peter Jamieson
http://tips.pjmsn.me.uk
On 21/01/2010 17:40, bryan wrote:
Posting again as I do not see this post.....
In order to get info from other systems, I need some info to start the sql
with.
Is it possible to pass in variable(s) when doing this:
Set objWord = objWordApp.Documents.Add("TemplateName")
Thanks,
Bryan
:
Yes you can action the formfields.
If you are creating a document from a template then use Document_New in the
template.
bryan wrote:
Since this template is locked and has formfields I'm assuming then that I
could tap into other systems to the populate the formfields, Correct?
Also,
would it be auto(new) or document(new) ?
Thanks,
Bryan
Use
[quoted text clipped - 51 lines]
Any idea of why this is happening?
.
--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/201001/1
.
.