passing a parameter to word template??

N

normanf

Hi there

I am wondering how I can resolve this issue.

With the below snipple of code I am calling a word
template, which after opened extracts the data it needs
from the access database, that has call word to open.

It works fine!

Now i have applied user access level security to the
database. In order to have the word template working
properly ( extracting the data from Access) I quickly
included Username, password and loaction of the secure
system mdw file. Everone can read the the password now, if
they open the word template vba.

I would like to pass the User logon name, userid and
loaction of the secure system mdw as parameter, whilst
opening the word template.( at statup)

any sugestions??

here is the current code:
'**************************************************
'myA_id = Id of record to call from word
'database and Template are in the directory / path
'mydb.name is that database that word extracts the data
from

Dim MyDB As Database, mobjWordApp As
Word.Application, MyDoc As Word.Document

Set MyDB = CurrentDb

On Error GoTo err_AuditTemplate

Const conTEMPLATE_NAME = "ATemplate.dot"

Set mobjWordApp = New Word.Application

mobjWordApp.Visible = True

Set MyDoc = mobjWordApp.Documents.Add(Template:=GetPath
(MyDB.Name, "Path") & "\" & conTEMPLATE_NAME)

MyDoc.ATemplate MyA_id, MyFull, MyDB.Name
DoEvents

mobjWordApp.Visible = True
*********************************************************
 
C

Cindy M -WordMVP-

Hi Normanf,

A couple of suggestions

1. You can protect the VBA code with a password. This isn't
super-protected, but would protect from casual "peeking"

2. You can pass parameters to procedures by using the .Run
method. It's also possible to pass parameters to procedures
in the ThisDocument class module if you've an object variable
set to that object.
I am wondering how I can resolve this issue.

With the below snipple of code I am calling a word
template, which after opened extracts the data it needs
from the access database, that has call word to open.

It works fine!

Now i have applied user access level security to the
database. In order to have the word template working
properly ( extracting the data from Access) I quickly
included Username, password and loaction of the secure
system mdw file. Everone can read the the password now, if
they open the word template vba.

I would like to pass the User logon name, userid and
loaction of the secure system mdw as parameter, whilst
opening the word template.( at statup)

any sugestions??

here is the current code:
'**************************************************
'myA_id = Id of record to call from word
'database and Template are in the directory / path
'mydb.name is that database that word extracts the data
from

Dim MyDB As Database, mobjWordApp As
Word.Application, MyDoc As Word.Document

Set MyDB = CurrentDb

On Error GoTo err_AuditTemplate

Const conTEMPLATE_NAME = "ATemplate.dot"

Set mobjWordApp = New Word.Application

mobjWordApp.Visible = True

Set MyDoc = mobjWordApp.Documents.Add(Template:=GetPath
(MyDB.Name, "Path") & "\" & conTEMPLATE_NAME)

MyDoc.ATemplate MyA_id, MyFull, MyDB.Name
DoEvents

mobjWordApp.Visible = True
*********************************************************

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun
8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top