473,836 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Shell to Word and load a specific document

Is there a way to shell to Microsoft Word from Access and load a specific
template - using VBA?

dixie
Aug 16 '06 #1
12 10692

Dixie wrote:
Is there a way to shell to Microsoft Word from Access and load a specific
template - using VBA?

dixie
Like this:
http://www.mvps.org/access/modules/mdl0043.htm

Aug 16 '06 #2
Or, you could use the simple Shell command

Call Shell("C:\progr am files\Microsoft Office\Office11 \winword.exe
h:\templates\te mplatetest.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
Aug 16 '06 #3
or possibly

Application.fol lowhyperlink "h:\templates\t emplatetest.dot "

Aug 16 '06 #4
I am using a template called "Rewards letter.dot".

When I use thecfollowing code:

Call Shell("C:\progr am files\Microsoft Office\Office\w inword.exe
f:\templates\(R ewards 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
"Tanis" <dn*****@accuri de.comwrote in message
news:11******** *************@b 28g2000cwb.goog legroups.com...
Or, you could use the simple Shell command

Call Shell("C:\progr am files\Microsoft Office\Office11 \winword.exe
h:\templates\te mplatetest.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

Aug 16 '06 #5
"Dixie" <di***@dogmail. comwrote in
news:12******** *****@corp.supe rnews.com:
I am using a template called "Rewards letter.dot".

When I use thecfollowing code:

Call Shell("C:\progr am files\Microsoft
Office\Office\w inword.exe f:\templates\(R ewards 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\w inword.exe" "f:\templates\R ewards Letter.dot"

To get that, you
Call Shell("""C:\pro gram 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" <dn*****@accuri de.comwrote in message
news:11******** *************@b 28g2000cwb.goog legroups.com...
>Or, you could use the simple Shell command

Call Shell("C:\progr am files\Microsoft
Office\Office1 1\winword.exe h:\templates\te mplatetest.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

Aug 16 '06 #6
I haven't seen this one before, but it works. The problem I see is that the
window that I am running the Access application in mimimises to the task bar
as soon as Word opens, then when I close word, it does not return to that
window automatically. If there was a way or getting the active Access
window back when you closed the Word document, this would be good.

dixie

"Ron2006" <ro******@hotma il.comwrote in message
news:11******** **************@ 75g2000cwc.goog legroups.com...
or possibly

Application.fol lowhyperlink "h:\templates\t emplatetest.dot "

Aug 16 '06 #7
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 the .dot
extension which is added in the code line.

Please?

dixie

"Bob Quintal" <rq******@sPAmp atico.cawrote in message
news:Xn******** **************@ 66.150.105.47.. .
"Dixie" <di***@dogmail. comwrote in
news:12******** *****@corp.supe rnews.com:
>I am using a template called "Rewards letter.dot".

When I use thecfollowing code:

Call Shell("C:\progr am files\Microsoft
Office\Office\ winword.exe f:\templates\(R ewards 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\w inword.exe" "f:\templates\R ewards Letter.dot"

To get that, you
Call Shell("""C:\pro gram 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" <dn*****@accuri de.comwrote in message
news:11******* **************@ b28g2000cwb.goo glegroups.com.. .
>>Or, you could use the simple Shell command

Call Shell("C:\progr am files\Microsoft
Office\Office 11\winword.exe h:\templates\te mplatetest.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

Aug 16 '06 #8
"Dixie" <di***@dogmail. comwrote in
news:12******** *****@corp.supe rnews.com:
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 the .dot extension which is added in the
code line.

Please?
Divide and conquer!

The first thing to do is move the dlookups to variables. Then
examine the contents of those variables after they have been
set. Also move the multiple quotes to a symbolic constant.

Dim filePath as string, filename as string
Const dQt as string = """"

filepath = DLookup("[LetterLabel]", "tblSetup", "ControlID=152" )
filename = DLookup("[Letter]", "tblLetters ", "ControlID= 49")

debug.print filepath, filename

'the resulting code is a lot easier to debug.
call shell(dQt & filepath & dQt _
& " " & dQt & filename & ".dot" & dQt _
& ")", 1)
--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Aug 17 '06 #9
Call Shell(DLookup("[LetterLabel]", "tblSetup", "ControlID=152" ) & " " &
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 there
is a space in it, then it doesn't work. So the problem with the above code
is that the 2nd DLookup returns a space in the name of the template and 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 "Commendati on 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" <di***@dogmail. comwrote in message
news:12******** *****@corp.supe rnews.com...
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 the
.dot extension which is added in the code line.

Please?

dixie

"Bob Quintal" <rq******@sPAmp atico.cawrote in message
news:Xn******** **************@ 66.150.105.47.. .
>"Dixie" <di***@dogmail. comwrote in
news:12******* ******@corp.sup ernews.com:
>>I am using a template called "Rewards letter.dot".

When I use thecfollowing code:

Call Shell("C:\progr am files\Microsoft
Office\Office \winword.exe f:\templates\(R ewards 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\R ewards Letter.dot"

To get that, you
Call Shell("""C:\pro gram 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" <dn*****@accuri de.comwrote in message
news:11****** *************** @b28g2000cwb.go oglegroups.com. ..
Or, you could use the simple Shell command

Call Shell("C:\progr am files\Microsoft
Office\Offic e11\winword.exe h:\templates\te mplatetest.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


Aug 17 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
7791
by: Jeff Harbin | last post by:
I've got an ACCESS 2000 application that I'm developing. One of the outputs of this app will be to generate a series of 'jobs' which corresponds to a record in the database. Each record will be printed on its own page which I've set up as a report and that's working fine. Accompanying each job is a Word (or Excel) document. Most jobs will have Word (or Excel) documents unique to the record. I know how to establish a hyperlink field...
3
4369
by: Bob | last post by:
What I want to do is write a program that reads through a Word Document, finds certain words or sentences I want, and then paste into an Excel spreadsheet. I dont know much about C#. But I learned how to use those COM Interop things. And Im able to write code that allows me to open existing Word documents and existing Excel spreadsheets. And I know how to write into specific columns and rows of the spreadsheet.
1
3661
by: Fei Yuan | last post by:
Please forgive me re-posting this question since I wasn't clear in my original post. --------> Starting an external process needs to pass it a ProcessStartInfo() object. ProcessStartInfo has a property "UseShellExecute" that can open/print a file. For example, here's a piece of code that launches an external process to open a Microsoft Word Document: Process p = new Process();
2
1944
by: KnotKnormal | last post by:
I would like to dynamically load a HTML page (or a Word document), which is embedded in a table when the user clicks on a hyperlink to go from HTML page one to HTML page two. For example, I would like the secretary at a school to update a Word document concerning homework assignments. This Word document would reside on the server. When changes are made it, these changes are automatically updated to the web page. This would simplify life...
7
6254
by: Dave | last post by:
Apologies for the newbie question. I have created a vb.net program for my company that is designed to work with Word Templates (about forty of them that we commonly use) that are selected by the user and populated (with info from an Access database) at run-time, then saved as Word documents. The program I have coded works fine -- it does what I need it to do. But it has two problems: (1) it runs very slowly, and (2) it does not seem to...
0
4020
by: funeeldy | last post by:
I need to locate a particular table in a document. I cannot hardcode the table number since it could be different in every doc. I do have some header text that comes right before it consistently, though. So, I tried to find that text, and then move to the next table. Then I need to add a row to the table which already has 4 columns. I need to maintain the old content of the table too. I think I am pretty close, but having a little trouble...
8
6989
by: Mike | last post by:
Am trying to open a Microsoft Word .doc file using Access 2000 with Shell function (on Windows XP Operating system) Here is the code : Shell "C:\Program Files\Microsoft Office\Office\Winword.exe O:\Patients Charts\mstest.doc" As soon as I try to open the same file on the O: drive (a directly connected server) , I get the following error message:"The document
4
12455
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is this: can Access create the document and place it as an OLE object to the relevant table? Any help is greatly appreciated. Ricky
0
3758
by: ppardi | last post by:
I'm developing an addin for Word 2007 and I need to determine whether a user saves a Word 2007 document in an older format (97-2003) after a save as is done. The scenario is that the user starts out with a Word 2007 document, saves that document to disk, then saves the same document in an older format If the user saves a doc in an older format, I want to turn off certain features of my add-in. I'm able to trap the save event easily...
0
10860
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10604
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6984
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5659
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5831
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4466
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4026
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3116
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.