Outlook and Word 
Author Message
 Outlook and Word

Hello, I've a little question to do.
I'm working with Outlook 98 and Exchange Server.
I've created a custom outlook form based on the example Help desk
application. The problem is that when I send the "help desk request" I would
to print  an outlook custom form based on a word document filling some form
fields.

I've created a outlook form and its'name is:
IPM.Document.Word.Document.8.Scheda Manutenzione Word AIVE

In the outlook office form there is a bookmark and a custom property named:
data

The code is:

Function Item_Send()

dim user
dim olemsession
Set olemsession = application.CreateObject("MAPI.Session")
returncode =
lemsession.Logon( application.GetNameSpace("MAPI").CurrentUser, "", False,
False, 0 )
Set user = olemsession.CurrentUser

Set HelpDeskFolder = item.parent

Set SchedaItem =
HelpDeskFolder.Items.Add("IPM.Document.Word.Document.8.Scheda Manutenzione
Word AIVE")

SchedaItem.FormFields("data") = item.SentOn
SchedaItem.PrintOut
End Function

But it doesn't work and I cannot guess why.
Anyone can help ?

Thanks Cristina



Mon, 26 Feb 2001 03:00:00 GMT  
 Outlook and Word
Cristina,

Quote:
> Set SchedaItem =
> HelpDeskFolder.Items.Add("IPM.Document.Word.Document.8.Scheda Manutenzione
> Word AIVE")

> SchedaItem.FormFields("data") = item.SentOn
> SchedaItem.PrintOut
> End Function

> But it doesn't work and I cannot guess why.
> Anyone can help ?

Please be more specific--How doesn't it work?  What error message and where
does it stop?

But it strikes me that the design is flawed.  You create a custom item, set
the SentOn date and issue the PrintOut method.  My guess is that it is
failing because you are setting the formfield("data") as soon as control
comes back to your code from the add method, but that this is before Word
has finished creating the item- as it has to load its runtime, then the
template, and bring up the screen.  The setting of formfield("data") should
be done in the Item_Open event of form IPM.Document.Word.Document.8.Scheda
Manutenzione.Word.AIVE, and the printout should be done on the Item_close of
that event.

I checked a similar form I did--the difference is I use a createObject to
get the Word document up.  Control didn't come back until it was all there.
 This may not be the problem in your case.  The problem I had was that I was
sending the PrintOut method, which was started in the background, control
came back to my code and I issued the Quit, which would have killed the
print task.  I had to include a parameter to do the printing in the
foreground, so that control didn't come back to my code until the print job
was completed.  My printout call was as follows:

        call myWordDoc.PrintOut( 0)

The Word Type Library help file says the parameter is supposed to be a
variant, so the call from VBScript should work. Others have had to call a
subroutine in the ThisDocument module in the template, which then issued the
PrintOut method.


 Sending from beautiful, midtown Mukilteo
 4.02 build 244 (32-bit)for WG, Win95, Thu, 10 Sep 1998 07:56 PDT



Mon, 26 Feb 2001 03:00:00 GMT  
 Outlook and Word
I agree with Hollis- I don't understand this code. I would think that
creating a separate instance of Word is the
way to go here as well. Create a Word document from a custom Word template
which contains bookmarks into
which you can copy your field contents, then print it:

Set objWord = Item.Application.CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open("document template.dot")

'for word fields
objWord.ActiveDocument.FormFields("word field name").Result =
UserProperties("outlook field name").Value _
    'for field in word

'for bookmark in word, instead of field, use these two lines
objDoc.Bookmarks("word bookmark name").range.select
objWord.Selection.Text = = UserProperties("outlook field name").Value

'You can use Hollis' technique to disable background printing, or wait for
background printing by using the
'.BackgroundPrintingStatus property of the Application object:

Do while objWord.BackgroundPrintingStatus > 0
Loop

Const wdDoNotSaveChanges = 0
doc.Close(wdDoNotSaveChanges)
objWord.Quit

Quote:

>Cristina,

>> Set SchedaItem =
>> HelpDeskFolder.Items.Add("IPM.Document.Word.Document.8.Scheda
Manutenzione
>> Word AIVE")

>> SchedaItem.FormFields("data") = item.SentOn
>> SchedaItem.PrintOut
>> End Function

>> But it doesn't work and I cannot guess why.
>> Anyone can help ?

>Please be more specific--How doesn't it work?  What error message and where
>does it stop?

>But it strikes me that the design is flawed.  You create a custom item, set
>the SentOn date and issue the PrintOut method.  My guess is that it is
>failing because you are setting the formfield("data") as soon as control
>comes back to your code from the add method, but that this is before Word
>has finished creating the item- as it has to load its runtime, then the
>template, and bring up the screen.  The setting of formfield("data") should
>be done in the Item_Open event of form IPM.Document.Word.Document.8.Scheda
>Manutenzione.Word.AIVE, and the printout should be done on the Item_close
of
>that event.

>I checked a similar form I did--the difference is I use a createObject to
>get the Word document up.  Control didn't come back until it was all there.
> This may not be the problem in your case.  The problem I had was that I
was
>sending the PrintOut method, which was started in the background, control
>came back to my code and I issued the Quit, which would have killed the
>print task.  I had to include a parameter to do the printing in the
>foreground, so that control didn't come back to my code until the print job
>was completed.  My printout call was as follows:

> call myWordDoc.PrintOut( 0)

>The Word Type Library help file says the parameter is supposed to be a
>variant, so the call from VBScript should work. Others have had to call a
>subroutine in the ThisDocument module in the template, which then issued
the
>PrintOut method.


> Sending from beautiful, midtown Mukilteo
> 4.02 build 244 (32-bit)for WG, Win95, Thu, 10 Sep 1998 07:56 PDT



Mon, 26 Feb 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. VBS Outlook and Word Template to Print

2. Please help me out: Import Contactitems from Outlook in Word

3. Outlook to Word

4. Sending email via Outlook from word 97/2000

5. Passing long filenames to Outlook from Word

6. Calling Outlook from Word

7. Outlook wdDialogFileNew (Word)

8. Write From Outlook To Word

9. Outlook / Calling Word App

10. Outlook Calling Word App

11. contact from outlook to word..

12. Outlook: Overriding Word HTML editor for a specific message

 

 
Powered by phpBB® Forum Software