HTMLData property for XLSpreadsheet in contracts form

I

IT Girl

I am using Office XP Professional, outlook 2002.

I am desiging a custom form, using the contact templete. In this templete I
have bound an XLSpreedsheet to one of the pages on my custom. I have added
the spreadsheet control to the form but I am having a problem with the data
retention in the spreadsheet after the form is published.

Sue Moshure was a fantastic help. She advised me that I need a code in the
form events that will provide a way to save the data and restore it when the
user opens or reopens the form. Creating this code is now a bigger
challenge for me then getting the spreadsheet imbeded in my form to begin
with.

Can some tell me or have a code that will alow the form user to enter data
in the spreadsheet that is imbedded in the contacts form, save this
information, then reopen this form and edit this data.
 
I

IT Girl

Thanks so much Sue.. But i still have a problem. I copies the code you
indicate below but when i open the form i get an error message of object
required: "oPage" line no:5 and it don't work for me? Any thoughts. To be
honest i do not know how to write one of these codes, so I really am at loss.
 
I

IT Girl

I did modify the code so that the page (Tab2) and control (Spreadsheet1)
matched up to the names on the on the form.

But when I open my newly created contact form to enter information I still
get a - Object Required: "oPage" Line No:5 message. And it will not retain
the information that I have entered on the spread sheet.

Any Ideas why?
 
I

IT Girl

Hi Sue... Thanks for the help by the way.. O.k. So this is the code.

Dim XLSheet

Function Item_Open()
Set XLSheet = Item.GetInspector.ModifiedFormPages("Tab2")
Set XLSheet = oPage.Controls("Spreadsheet1")
XLSheet.HTMLData = Item.Body
Item.Subject = Trim(Item.Subject & " ") 'Dirty the form
End Function

Function Item_Write()
Item.Body("XLSheet") = XLSheet.HTMLData
End Function

I rechecked the Contral and page name just to make sure i have them right
and in the right places.
 
S

Sue Mosher [MVP-Outlook]

If you look at these two statements and compare with the source code at
http://www.outlookcode.com/article.aspx?id=69, you should see your mistake:

Set XLSheet = Item.GetInspector.ModifiedFormPages("Tab2")
Set XLSheet = oPage.Controls("Spreadsheet1")

You have two statements instantiating an object variable named XLSheet, when
what you need is one statement to instantiate a variable named oPage, then a
second statement to instantiate XLSheet.
 
I

IT Girl

I have made the corrections you noted. But I am still getiing the the same
script error when I open the contact and then when I update the information,
save and close I get another error of - Object required: 'XLSheet' Line No.
11. Did I miss something Sue?

Here's the code again.

Dim XLSheet

Function Item_Open()
Set oPage = Item.GetInspector.ModifiedFormPages("Tab2")
Set XLSheet = oPage.Controls("Spreadsheet1")
XLSheet.HTMLData = Item.Body
Item.Subject = Trim(Item.Subject & " ") 'Dirty the form
End Function

Function Item_Write()
Item.Body("XLSheet") = XLSheet.HTMLData
End Function

If I can't get this to work, I have an alternate solution I would like to
try. But I have encountered a problem with that one as well.

For my alternate solution I have used a button control on a tab in my
contact form to launch an XL Sheet. This would work as well, just not what I
was hoping to do for this purpose. The problem with this option is the
command code launches the pre-set XL-sheet from the D drive of my computer.
This contact form design is to be used on the public drive and I would need
the code to instruct the XL-Sheet to launch form the public drive so all who
have access can get the same information. Is this possible? If it is easier
to get working then I would go this route and forget my original design. I
have the code that launchs form the D-drive for this alternate option if it
helps? Can it be cchanged to launch an ex-sheet form the public drive?

Sub GroupINFO_Click

Set objExcelApp = Item.Application.CreateObject("Excel.Application")
objExcelApp.Workbooks.Open("GroupINFO.xls")
Set objExcelBook = objExcelApp.ActiveWorkbook
Set objExcelSheets = objExcelBook.Worksheets
Set objExcelSheet = objExcelBook.Sheets(1)
objExcelSheet.Activate
objExcelApp.Application.Visible = True

End Sub

-
IT Girl
 

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