Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming Forms / April 2009

Tip: Looking for answers? Try searching our database.

Custom form created in 2003 won't print since upgrade to 2007

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lori_CB - 29 Apr 2009 21:03 GMT
We created multiple Outlook forms that print to Word templates via code in a
Print button.  The forms were created in 2003.  We recently upgraded to 2007.
Now, when we click the button, the Word template prints but it doesn't
contain the information from the form.

Any ideas?
Sue Mosher [MVP] - 29 Apr 2009 22:17 GMT
Code in a print button on the form or in Word? You may want to add MsgBox
statements to the code to help you see how it's branching and executing.
Signature

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

> We created multiple Outlook forms that print to Word templates via code in
> a
[quoted text clipped - 4 lines]
>
> Any ideas?
Lori_CB - 29 Apr 2009 22:27 GMT
The code is for the Print button on the Outlook form.  It's used to open
Word, populate the Word fields, print the document and close Word.

> Code in a print button on the form or in Word? You may want to add MsgBox
> statements to the code to help you see how it's branching and executing.
[quoted text clipped - 6 lines]
> >
> > Any ideas?
Sue Mosher [MVP] - 29 Apr 2009 22:52 GMT
Did you try what I suggested? Or run the code in the script debugger?
Signature

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

> The code is for the Print button on the Outlook form.  It's used to open
> Word, populate the Word fields, print the document and close Word.
[quoted text clipped - 11 lines]
>> >
>> > Any ideas?
Lori_CB - 29 Apr 2009 23:00 GMT
I tried the msgbox and the fields are getting filled in properly.

When I try to use the Script Debugger, it says the feature is not available
and to run setup again.  I'm waiting for a reply from our Help Desk.

> Did you try what I suggested? Or run the code in the script debugger?
> > The code is for the Print button on the Outlook form.  It's used to open
[quoted text clipped - 12 lines]
> >> >
> >> > Any ideas?
Sue Mosher [MVP] - 29 Apr 2009 23:55 GMT
Script debugger is an optional component that may not have been installed;
it definitely won't work on Vista unless you also have Visual Studio. :(
That's why I suggested using MsgBox statements.

What do you mean by "the fields are getting filled in properly" -- the
fields in the Outlook item or the fields in the Word document? What happens
if you change the code so that the Word document displays instead of being
printed?
Signature

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

>I tried the msgbox and the fields are getting filled in properly.
>
[quoted text clipped - 23 lines]
>> >> > doesn't
>> >> > contain the information from the form.
Lori_CB - 30 Apr 2009 13:59 GMT
We have XP Professional, so I'm hoping to get it back.  It's another thing
that stopped working after the upgrade.  There must be something to tweak.

I did a message box for the Outlook field value and for the Word field
value.  Both were correct.

I changed oDoc.PrintOut to oDoc.Display and got the following error message:
"Object doesn't support this property or method: 'oDoc.Display'"

Should I be changing something else too?

Thanks for all your help and patience.

> Script debugger is an optional component that may not have been installed;
> it definitely won't work on Vista unless you also have Visual Studio. :(
[quoted text clipped - 31 lines]
> >> >> > doesn't
> >> >> > contain the information from the form.
Sue Mosher [MVP] - 30 Apr 2009 14:11 GMT
The object browser (F2 in VBA) is your friend. If you look at the Document
object in the Word library, you'll see that it has no Display method, but it
does have an Activate method and Window.Visible property.

You might want to show enough of your code so we can see how you're creating
the document and printing it. Please DO NOT show all the code for filling
the fields; as you said, it's clear that's working.

Signature

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

> We have XP Professional, so I'm hoping to get it back.  It's another thing
> that stopped working after the upgrade.  There must be something to tweak.
[quoted text clipped - 50 lines]
>> >> >> > doesn't
>> >> >> > contain the information from the form.
Lori_CB - 30 Apr 2009 14:42 GMT
The code I've been referring to is in Outlook, not Word.

Here's what I'm doing when trying to display the Word document
(see <<< comments in the code):
Sub cmdPrint_Click()
     Set oWordApp = CreateObject("Word.Application")
     If oWordApp Is Nothing Then
        MsgBox "Couldn't start Word."
     Else
        Dim oWordApp
        Dim oWordDoc
        Dim bolPrintBackground

        ' Open a new document
        Set oDoc = oWordApp.Documents.Add
("\\w2kcbutler\data\eforms\pcrenewal2.dot")

        ' <<< deleted setting the field values

        ' Get the current Word setting for background printing
        bolPrintBackground = oWordApp.Options.PrintBackground

        ' Turn background printing off
        oWordApp.Options.PrintBackground = False

        ' Print the Word document
        'oDoc.PrintOut    <<< commented out
        oDoc.Display  <<< added

        ' Restore previous setting
        oWordApp.Options.PrintBackground = bolPrintBackground

        ' Close and don't save changes to the document
        'Const wdDoNotSaveChanges = 0    <<< commented out
        'oDoc.Close wdDoNotSaveChanges    <<< commented out

        ' Close the Word instance
        'oWordApp.Quit     <<< commented out

        ' Clean up
        Set oDoc = Nothing
        Set oWordApp = Nothing
     End If
  End Sub
Sue Mosher [MVP] - 30 Apr 2009 16:37 GMT
The code may be in Outlook, but you're using Word objects, so you need to
pay attention to what properties and methods those objects expose. Don't
assume you know what they are; look them up in the object browser.

Did you try using the Activate method I pointed out?

Signature

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

> The code I've been referring to is in Outlook, not Word.
>
[quoted text clipped - 40 lines]
>      End If
>   End Sub
Lori_CB - 30 Apr 2009 16:50 GMT
I tried the Activate and PrintPreview methods.  Each time, nothing happened
when I clicked the Outlook Print button.
Sue Mosher [MVP] - 30 Apr 2009 17:11 GMT
You can also try adding a statement to set the document's
ActiveWindow.Visible property to True.

You might also want to comment out any On Error Resume Next statement so you
can get a better handle on any errors that may be occurring.

Signature

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

> I tried the Activate and PrintPreview methods.  Each time, nothing
> happened
> when I clicked the Outlook Print button.
Lori_CB - 30 Apr 2009 19:33 GMT
You are a goddess!  

The ActiveWindow.Visible property and PrintPreview let me see the
information is on the form.

I added some message boxes so I know the form was filled out before the
PrintPreview statement and then after the PrintPreview statement.

When it hit the PrintOut statement, it cleared the form then did the actual
print.

Here's the code I used to test it.
        ' Print the Word document
    msgbox "before preview"
        oDoc.PrintPreview
    msgbox "after preview"
        oDoc.PrintOut   
    msgbox "after printout"

Now, I know it's the PrintOut statement that's causing the problem.

This has been driving me crazy for a week....thank you for saving my sanity.
Sue Mosher [MVP] - 30 Apr 2009 21:03 GMT
Wow, that sounds quite odd, but at least you can print it manually once you
have it in preview. You might want to ask in a Word forum about why the form
fields are clearing.

Signature

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

> You are a goddess!
>
[quoted text clipped - 20 lines]
> This has been driving me crazy for a week....thank you for saving my
> sanity.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.