Open File from Command Button

T

taborp

I have created a custom form, but would like to set a command button to open
a Word file located in a network folder. The path to the Word file is
G:\Information System\Electronic Communications Policy. I know I need to
start with Sub CommandButton1_Click(), but then do not know what else to
enter. Can anyone help? Thanks.
 
E

Eric Legault [MVP - Outlook]

You cannot directly open a file or cause a program to start by using
VBScript. You need to call something that implements this functionality
(such as the Win32 API Shell function), either in an Outlook macro or Add-In
or a custom DLL.
 
S

Sue Mosher [MVP-Outlook]

Since it's a Word file, you can use Word automation, along these lines:

Sub CommandButton1_Click()
strPath = "G:\Information System\Electronic Communications Policy.doc"
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open(strPath)
objDoc.Activate
End Sub
 
T

taborp

Hey Sue:

this code worked great as long as I was in design view, using the run code
option. When I actually email the form to myself, the command buttosn do not
work when I open the form message. Any ideas?
 
T

taborp

Never mind...it was that pesky "send definition with form" item - it was
checked, and I needed to uncheck it. Thanks.

Penny
 
W

Will

Sue,

Is it possible to program a command button to launch a Word document with
fillable data fields in the document and, once the user has completed filling
in the fields, they close the document and the document is saved in the
Contact Notes field?

For example, an employee at a remote site navigates to our functional
mailbox and to the Incident Report folder. Clicks on NEW POST. In the
folder, we would create a custom POST form in which the employee fills
standard reporting data, then clicks a button launching a Word document in
which they complete their detailed report.

Conversely, I'd like to program a button to launch a Word document and
populate fields in the document with data the user enters into the Contact
page. In this example, an employee navigates to our Public Folder in which
there is a Contact folder containing employee data. The user goes to a
custom page in which the employee enters R&R request data. I need a button
on page 2 that would send the request data, (dates, specific airline
carriers, frequent flyer numbers, destination, etc), to the individuals
supervisor. The supervisor, in turn, will have a button to APPROVE the
request. When the APPROVAL even is activated, the supervisor's signature
file will be applied to the document. The employee can then click a button
on their end which would print a pre-designed document with fields populated
from the form along with the signature of the supervisor.

That's a lot.

I'm buying the book... but I'd like some guidance.

Thanks!

C
 
S

Sue Mosher [MVP-Outlook]

Creating such a document is a pretty straightforward Word automation project. By "the document is saved in the Contact Notes field," do you mean that you want to attach the document after the user has worked with it? That would be a little more complicated, but not difficult. You'd need to have something in the document -- maybe a custom property holding the EntryID of the original contact -- that would allow the event that fires when the document is closed to find the related Outlook item and attach the document. You'd need either an add-in or a network location to store the Word .dot template files.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
W

Will

It is?? Ok.. so what..I would create the Word doc and include Mail Merge
fields or what?

Yes.. I want the user to enter the information into the Word doc and then
have the doc saved back into the Outlook item. So, for example, a user opens
a leave request form and the form along with the data entered into the form
are saved in the users contact Notes filed. Even more- I'd like the data
entered into the form to populate custom fields in the custom Contact form as
well.

I have a place to hold the templates on the server, or I can send the
template out to the individuals either way..

I know nothing about add-in's.

This is going to either get really complicated or expensive. I either have
to learn this on my own or dump the project. There's no funding available to
sub-contract this out to a programmer. Is this type of process something one
can learn from your book? I ordered it today.

Thanks for your guidance.

C

PS: I'm willing to send you the contact page I've built if you're willing to
look at, however, w/out being here, there's not much to learn from looking at
the page itself.

PSS: Also, on another note, I am having difficulty assigning a button to
Phone 5 Selector. On the original template there are 4 command buttons each
called Phone#Selector, #=1-4 respectively. I first attempted to copy the
button and reassign the Value, binding it to Phone 5 Selector, however, the
only options available in the All Contacts Fields are Categories, Check
Address, Check Name, Contacts, Edit Yomi and Flag Color. The fields that are
normally there are simply not. I assume this has to do w/the fact that I'm
looking to bind the command button and not a text field, however, I'm not
sure. Anywhoo, second, I attempted to create my own command button instead
of copying it. I only copied it b/c I wanted to maintain the black downward
pointing triangle picture that is on the standard four buttons on the new
buttons I created. Guess I'll have to go through the trouble of finding the
picture and applying it to the new command button.. regardless, however, the
same issue is there. I am unable to bind the button Value to the Phone 5
Selector Field. I had no issues w/binding the text box I created, however to
display the Phone 5 Selected field. Ugh!

Thanks!

C
 
S

Sue Mosher [MVP-Outlook]

Yes, this is a complicated project -- straightforward, because no "tricks" are involved, but complex because you want to pass data from Outlook to Word, and then back again.

Add-ins are covered in books by Randy Byrne and others. My books concentrate on the basics.

I'm still not clear on whether ("have the doc saved back into the Outlook item") means attaching a Word document or filling Outlook contact fields or both.

As for Phone Selector 5, you should be able to drag it to the form from the Field Chooser.

You might want take a look at the samples at http://www.outlookcode.com/article.aspx?ID=24 that use Word for printing. They use techniques that would be relevant for your project.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


Will said:
It is?? Ok.. so what..I would create the Word doc and include Mail Merge
fields or what?

Yes.. I want the user to enter the information into the Word doc and then
have the doc saved back into the Outlook item. So, for example, a user opens
a leave request form and the form along with the data entered into the form
are saved in the users contact Notes filed. Even more- I'd like the data
entered into the form to populate custom fields in the custom Contact form as
well.

I have a place to hold the templates on the server, or I can send the
template out to the individuals either way..

I know nothing about add-in's.

This is going to either get really complicated or expensive. I either have
to learn this on my own or dump the project. There's no funding available to
sub-contract this out to a programmer. Is this type of process something one
can learn from your book? I ordered it today.
 
W

Will

Ok.. I'll look up the books by Randy Byrne.

I thought I wanted to do both.. but the more I learn.. the less important it
becomes to have the document saved in the contact. What I ultimately want is
to eliminate paper. Our company prints reports and forms, fills them out,
scans them to a supervisor for signature who scans and sends them back.. then
the employee signs them and turns them in. Unbelievable! I'm working on
them to move towards e-signatures and using logon ID for verifications and so
forth. Very slow process. So what I want to do is have a VERY complete
streamlined VERY user-friendly product that still provides the capability to
print their forms out. Then I'll wean them off that too.

I was, in fact, able to drag both the command button and the corresponding
text box from the selector.. however, the icon on the button is not there.
Does MS have a location of standard icons for Outlook programming they use
and make available somewhere. I know.. it's a simple tri-angle.. something
REALLY easy for those individuals who work with this stuff every day.. I
don't, however, and I spend a great deal of time just looking for
information. I figure I would just be able to copy one of the other command
buttons and re-bind it...but alas.. no. Simply not an option.

Thanks!

C
 

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