programming a spreadsheet within an outlook form

  • Thread starter Thread starter Ken Marshall
  • Start date Start date
K

Ken Marshall

I am trying to design a form with a spreadsheet on a page, and be able to
programmatically work with it. I found this code in the help file, but it
gives me an error.

Sub List_All_Names()
Dim nmCurrentName
Dim rngCurrent

Set rngCurrent = Spreadsheet1.ActiveSheet.Range("A1")

' Loop through all of the names in the active workbook.
For Each nmCurrentName In Spreadsheet1.ActiveWorkbook.Names

' Write the current name to the worksheet.
rngCurrent.Value = nmCurrentName.Name

' Write the definition of the current name to the worksheet.
rngCurrent.Offset(0, 1).Value = "'" & nmCurrentName.RefersTo

Set rngCurrent = rngCurrent.Offset(1, 0)
Next
End Sub

When it gets to the set statement, it ends with the error "object required."
There is obviously something I am missing, perhaps another set statement, or
perhaps a reference I need to make in the Tools/References list.

Your help is appreciated.
Neil
 
Thanks Sue for the reply

I tried the lines of code to instantize Spreadsheet1, but came back with
the error
Runtime errir 424 Object required.

So where do I go from here?

thanks
Neil
 
Show the code statement(s) that resulted in that error.

Also note: The newsgroup interface you are using apparently does not quote
earlier messages in the thread, making your latest message so short on
detail that you risk not getting the answer you're looking for. Please take
the time to quote the original message.
 
Sue - thanks for being so patient with me, I am new to this newsgroup,
and programming Outlook.

I am trying to programatically enter information into a spreadsheet on
an Outlook form. The code I am using is:

Sub xlInformation()
Dim nmCurrentName
Dim rngCurrent

Set opage = Item.GetInspector.ModifiedFormPages("Sales")
Set Spreadsheet1 = opage.Controls("Spreadsheet1")

Set rngCurrent = Spreadsheet1.ActiveSheet.Range("A1")

' Loop through all of the names in the active workbook.
For Each nmCurrentName In Spreadsheet1.ActiveWorkbook.Names

' Write the current name to the worksheet.
rngCurrent.Value = nmCurrentName.Name

' Write the definition of the current name to the worksheet.
rngCurrent.Offset(0, 1).Value = "'" & nmCurrentName.RefersTo

Set rngCurrent = rngCurrent.Offset(1, 0)
Next
End Sub

At the very first Set statement, I get a Runtime error 424 object
required error. Any help will be appreciated.


thanks
Neil
 
So this is code behind an Outlook form? And this statement is the problem?

Set opage = Item.GetInspector.ModifiedFormPages("Sales")

You should check whether Sales is the actual name of the form page or
whether it has a leading or trailing space.
 
Sue

There are no spaces in the page name.

I am not sure if I understand correctly your question "this is the code
behind an outlook form?" I believe that is correct, however let me
check. Yes, I have an Outlook form (a modified Contact form) with an
added page named Sales. This sub runs when the form is open. I intend
to get information from the contact, search a database, and fill the
spreadsheet with information. I know that the sub I list will not do
that, but I am trying to write a small amount of code to test if I can
do it before I spend the time necessary for the whole job.

thanks
Neil

ps just in case the reply does not have the code, here is part of it:
 
Unfortunately, if you're getting an "object not found" error from this
statement:

Set opage = Item.GetInspector.ModifiedFormPages("Sales")

it's hard to imagine what the problem could be other than the page not being
named "Sales."

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Back
Top