Re: Shell to Word and load a specific document
- From: "Dixie" <dixie@xxxxxxxxxxx>
- Date: Fri, 18 Aug 2006 07:16:08 +1000
I actually used Bob Quintal's approach. It returned the correct filepath
and filename in the Immediate window, but it the entire expression still did
not locate the file when opening Word. It was giving an error message "The
file Commendation Letter.dot) is not available" (in other words, it was
appending the parenthesis onto the filename.) I already knew I had a
problem with quotation marks in the second DLookup and was working on that
yesterday before I had to go out.
Thankyou everyone who has helped me. The last expression from Terry was
what I was looking for and I DO know I need to brush up on my use of
multiple quotation marks in such expressions. My problem is they crop up so
infrequently.
dixie
"Terry Kreft" <terry.kreft@xxxxxxxxx> wrote in message
news:XtudnQbO49lk5nnZnZ2dnUVZ8t2dnZ2d@xxxxxxxxxxxxxxxxx
You've dropped your embedded double quotes again.
It should be
Call Shell(DLookup("[LetterLabel]", "tblSetup", "ControlID=152") & " """ &
CurrentProject.Path & "\Templates\" & DLookup("[Letter]", "tblLetters",
"ControlID=49") & ".dot""", 1)
or if you look at Bob Quintal's post where he starts with the words
"Divide
and conquer!", he illustrates the way a programmer would approach this in
order to break the problem down into manageable bits.
--
Terry Kreft
"Dixie" <dixie@xxxxxxxxxxx> wrote in message
news:12e7fkq39nmuk34@xxxxxxxxxxxxxxxxxxxxx
Call Shell(DLookup("[LetterLabel]", "tblSetup", "ControlID=152") & " " &there
CurrentProject.Path & "\Templates\" & DLookup("[Letter]", "tblLetters",
"ControlID=49") & ".dot", 1)
I've just discovered that the above code works perfectly correctly if the
template name in the Letter field of tblLetters is only one word. If
is a space in it, then it doesn't work. So the problem with the abovecode
is that the 2nd DLookup returns a space in the name of the template andthe
it
can't work. That suggests to me some extra inverted commas for the
second
DLookup only, but I can't seem to work out how to do it.
I have also noticed that if I put inverted commas around the actuall
template name in tblLetters such that it is "Commendation Letter" in the
table, it works fine. I don't really want to do it that way however if I
can solve it with some inverted commas in the code.
dixie
"Dixie" <dixie@xxxxxxxxxxx> wrote in message
news:12e7cm0khg29m96@xxxxxxxxxxxxxxxxxxxxx
OK, that works fine. Now, I need to make this generic. I need to
substitute some DLookups for the path to Word and for the path to the
template. I have used this sort of stuff before, but not in the Call
Shell context.
This is sort of what I am looking to do:
Call Shell("DLookup("[LetterLabel]", "tblSetup", "ControlID=152") &" "
&
CurrentProject.Path & "\Templates\" & DLookup("[Letter]", "tblLetters",
"ControlID=49") & ".dot")", 1)
Needless to say, it is not working and I get an Expected list separator
or ) error. Again, I feel this should work, but I am tangled in
quotations again.
The DLookup on tblSetup returns the full path to winword.exe and the
DLookup on tblLetters gives me the basic letter template name without
.dot extension which is added in the code line.
Please?
dixie
"Bob Quintal" <rquintal@xxxxxxxxxxxxx> wrote in message
news:Xns9821BD41D561BBQuintal@xxxxxxxxxxxxxxxx
"Dixie" <dixie@xxxxxxxxxxx> wrote in
news:12e75osn44r3306@xxxxxxxxxxxxxxxxxx:
I am using a template called "Rewards letter.dot".
When I use thecfollowing code:
Call Shell("C:\program files\Microsoft
Office\Office\winword.exe f:\templates\(Rewards Letter.dot)",
1)
Word opens and then says "The file rewards.doc is not
available." How do I handle the two word template name? Is
there some way of doing it with different quotation marks?
dixie
Yes.
what you want in the command is "C:\program files\Microsoft
Office\Office\winword.exe" "f:\templates\Rewards Letter.dot"
To get that, you
Call Shell("""C:\program files\Microsoft Office\Office
\winword.exe""
""f:\templates\Rewards Letter.dot""", 1)
The rule is to use two doublequotes to embed one doublequote in
the string. Then quote the entire string as usual.
"Tanis" <dneagle@xxxxxxxxxxxx> wrote in message
news:1155736056.147008.12800@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Or, you could use the simple Shell command
Call Shell("C:\program files\Microsoft
Office\Office11\winword.exe h:\templates\templatetest.dot",
1)
Just change the pathname to suit.
Dixie wrote:
Is there a way to shell to Microsoft Word from Access and
load a specific template - using VBA?
dixie
--
Bob Quintal
PA is y I've altered my email address.
--
Posted via a free Usenet account from http://www.teranews.com
.
- References:
- Shell to Word and load a specific document
- From: Dixie
- Re: Shell to Word and load a specific document
- From: Tanis
- Re: Shell to Word and load a specific document
- From: Dixie
- Re: Shell to Word and load a specific document
- From: Bob Quintal
- Re: Shell to Word and load a specific document
- From: Dixie
- Re: Shell to Word and load a specific document
- From: Dixie
- Re: Shell to Word and load a specific document
- From: Terry Kreft
- Shell to Word and load a specific document
- Prev by Date: Re: Conditonal formatting
- Next by Date: Re: If statement for an Open Event if button click
- Previous by thread: Re: Shell to Word and load a specific document
- Next by thread: querydef........
- Index(es):