Issue with returnable form

G

Gary Newport

Hi. This is my first posting here so I thought I'd start off with a wave.
{wave} :blush:)

Okay, I am building a form as a round robin. Basically, when we have an
issue relating to a student, a relevant senior member of staff will send the
form to all relevant staff. The original form will have the student's name,
the date of return and the reason for the concern.

The receiver is to then fill out further information relevant to their area
of work and then return the form to the original source.

To simplify everything I have created a button, entitled Return Form and
named btnReturn. I have then entered the code:

sub btnReturn_click()
item.send
end sub

I cannot see how this will send the form back to the correct person but I
have even put a simple msgbox statement in the code and nothing happens. Do I
place this code in the Script window or in the VBA editor for the current
session?

Equally, I have created the compose view and the read view. So, when it is
returned, is it the read view that is viewable to the original sender?

But primarily, how do I get this button to work?

Sorry for the barrage of questions but whilst I await a new book I could do
with some serious assistance here.
 
S

Sue Mosher [MVP-Outlook]

The first issue we need to tackle is whether it's possible for you to
implement any custom message forms with VBScript code at all. Do you have
permission to publish forms to the Organizational Forms library on your
company's Exchange server? If not, then Outlook forms are not likely to be a
practical solution. You would need to give each person a copy of the form
along with instructions on how to publish it to their own Personal Forms
library. And you'd have to do that again every time you made a change to the
form.
 
G

Gary Newport

I have full permission to the organisational library.

As further information, We are using Exchange 2003 with Outlook 2003 as the
client application; though the network manager is intending to move to
Outlook 2007 soon. I will, however, continue to design forms for Outlook 2003
for the foreseeable time, until the roll-out can be guaranteed as 100%
coverage and reliable. :blush:)
 
S

Sue Mosher [MVP-Outlook]

In that case, to allow code to run for both senders and recipients inside
your organization, make sure you publish the form to the Organizational Forms
library with the "send form definition with item" box on the (Properties)
page always unchecked.

As for the specific code, one solution would be to forward the item back to
the original sender. You can do that with this code:

Sub btnReturn_click()
Set fwd = Item.Forward
fwd.To = "[EX:" & Item.SenderEmailAddress & "]"
If fwd.Recipients.ResolveAll Then
fwd.Send
Else
fwd.Display
End If
End Sub

If you use that approach, on the (Actions) page of the form, make sure you
set the Forward action to use the published form.

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

Gary Newport

Thanks for this.

One more stupid question; does thi code into "View Code" or directly into
the currentsession of the VBA Editor?

Sue Mosher said:
In that case, to allow code to run for both senders and recipients inside
your organization, make sure you publish the form to the Organizational Forms
library with the "send form definition with item" box on the (Properties)
page always unchecked.

As for the specific code, one solution would be to forward the item back to
the original sender. You can do that with this code:

Sub btnReturn_click()
Set fwd = Item.Forward
fwd.To = "[EX:" & Item.SenderEmailAddress & "]"
If fwd.Recipients.ResolveAll Then
fwd.Send
Else
fwd.Display
End If
End Sub

If you use that approach, on the (Actions) page of the form, make sure you
set the Forward action to use the published form.

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




Gary Newport said:
I have full permission to the organisational library.

As further information, We are using Exchange 2003 with Outlook 2003 as the
client application; though the network manager is intending to move to
Outlook 2007 soon. I will, however, continue to design forms for Outlook 2003
for the foreseeable time, until the roll-out can be guaranteed as 100%
coverage and reliable. :blush:)
 
S

Sue Mosher [MVP-Outlook]

Code for a custom form goes into the form's code editor (View Code). VBA code
is an entirely separate code environment.
 
G

Gary Newport

Thanks for this. I will give it all a try tomorrow. The fun of learning, eh?
 
G

Gary Newport

Hi Sue again!

Okay, I have tried several times to put the code in but every time I close
the form the code disappears; lost into the ether! :blush:(

Do you know why? Am I missing a permissions thing (which I can get changed)
or am I doing something wrong?

I am using Outlook 2007, using View Code and pasting the code in, clicking
on Publish and then save. I am now saving to the organisational library area
(I am the only one working ion there and the employees know not to use the
form yet).

Help please! :blush:)
 
S

Sue Mosher [MVP-Outlook]

I don't quite follow what you mean by "clicking on Publish and then save."
Publishing a form and saving an item are two entirely different things. After
you publish the form, to use that form, you can launch a new item with it
using the Tools | Forms | Choose Form command. If you want to design it again
(and see the code), use Tools | Forms | Design a Form.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
G

Gary Newport

Sorry, keep creating confusion.

I save the form when I feel it is at a stage where I want to see it
function. I then publish it. As a matter of protection I then go to save it
again (in case the publishing has an impact on the form) and then close the
form.

I then open the form in the Tools>Forms>Choose Form... or the
File>New>Choose Form.. route.

What I am finding is that, if I click on View Code and then paste your code
into the window, close the window, save and publish then I find that when I
run the form the button does nothing. When I return to design the form there
is nothing in the View Code window at all.

Slightly separately, is the View Code window generalistic (therefore all
code for the form will appear in there) or is it object-based (should I be
clicked on the button to apply the code for the button)?

Hope I have not added confusion.
 
S

Sue Mosher [MVP-Outlook]

The View Code window is just a text editor. If you don't see the code, trying
using PgDn. I recall a bug in early Outlook 2007 versions where the code
didn't show unless you paged down.

Also, saving the item, i.e. clicking the Save button, does nothing useful at
all. Don't waste your time. The right way to make a backup copy of a form is
to use the Save As command to save it as an .oft file.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
G

Gary Newport

Thanks Sue.

However, this still takes me back to my original problem then.

I publish the form to the Organisational Forms Library, I then File > New >
Choose Form... and select my form. I complete the active elements (the form
is made up of enabled and disabled elements, which I may simply remove) and
then send it to myself (for checking purposes).

The form arrives with the completed fields correct and I am able to add to
the newly enabled fields. However, when I click on the button...nothing.
Diddley squat. Zilch.

I can repeatedly click and nothing happens at all. I'd expect the message to
close and a new message appear (since I was the sender) but... nothing!

Why not? The Network Manager has confirmed that macros are enabled by
default and that I have full, administrative permissions on the library.
 
S

Sue Mosher [MVP-Outlook]

Did you make sure that the form was published with the "Send form definition
with item" box on the (Properties) page unchecked? Is the button actually
named "btnReturn" to match the name of the Click event handler? Does the
item show the MessageClass value of your published custom form, i.e.
IPM.Note.Something? Have you tried adding MsgBox statements to the code to
get a better idea of what's executing?
 
G

Gary Newport

Did you make sure that the form was published with the "Send form
definition with item" box on the (Properties) page unchecked?

Have now! Didn't before. What does this mean, please?
Is the button actually named "btnReturn" to match the name of the Click event handler?

Yes. Double checked by yes! :blush:)

Does the
item show the MessageClass value of your published custom form, i.e. IPM.Note.Something?

Pardon? Sorry but where is this, what is this and why? Oh I feel like I'm
regressing! :blush:)
Have you tried adding MsgBox statements to the code to get a better idea of what's executing?

Have throughout this form. Just would like a response at some time.

I am incredibly grateful for all your help, by the way.
 
S

Sue Mosher [MVP-Outlook]

The "Send form definition with item" box is an obsolete setting that no
longer has any utility. It should always be unchecked. If it was previously
checked and you unchecked it, you must republish the form.

The value of the MessageClass property determines what form Outlook will use
to display the item. You set the form display name and message class when you
published the form. You can see these message class values for individual
items by adding the Message Class field to a table view.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
G

Gary Newport

Thanks for all of this Sue. Has worked really well.

I have also found that I need to publish to both the Organisational Forms
Library and my Personal Forms Library to ensure changes migrate properly. I
need to now develop an effective working practice to know which one I have
changed!

Three further questions and then I promise to leave you alone...

1. Can you delete forms from your Personal Forms Library, once you have
finished developing?

2. I'd like the form subject to contain reference to a completed field on
the Compose field. I tried this but it did not work. Where am I going wrong?

Function Item_Send()

Set MyEmailSubject = Item.UserProperties.Find("txtEmailSubject")
Set MySendStudent = Item.UserProperties.Find("txtSendStudent")
MyEmailSubject.value = "Round Robin for " & MySendStudent.value

End Function

3. When the form returns to the sender, the form fields that can be
completed by the receiver are still enabled and therefore editable. How can I
stop this?

I did try this within the btnReturn_click() but it failed also.

Set MySubject = Item.UserProperties.Find("txtSubject")
MySubject.enabled = false
 

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