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 / February 2007

Tip: Looking for answers? Try searching our database.

Accessing the function across the forms.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mani - 22 Feb 2007 22:40 GMT
Hi,

I have developed the Custom Form with various user defined functions. My
requirement is to use the same functions in different custom forms. I could
not able to call the functions (Getting an error "object doesn't support this
property or method" ). For example,

Function GetNewItem()
    Dim nameSpace, inbox, newItem
    Set nameSpace = Application.GetNameSpace("MAPI")
    Set inbox = nameSpace.GetDefaultFolder(6)
    Set newItem = inbox.Items.Add("IPM.Note.GeneralNavigation")
    Set GetNewItem = newItem
End Function

sub cmdimport_click()
    dim doc
    dim st
    set doc=GetNewItem() 'Object created.
    set st=xmldoc.getusername() 'Getting error here.
end sub

Please give me the solution on this.
I appreciate your help.

Thanks,
Mani
Sue Mosher [MVP-Outlook] - 22 Feb 2007 22:54 GMT
This may sound obvious, but whatever code you want to run each form to run needs to be present in that form's code editor window.

It's not at all clear from what you posted what xmldoc is supposed to be. If you're calling an external component, you need to instantiate that component first.

Signature

Sue Mosher, Outlook MVP
  Author of Configuring Microsoft Outlook 2003
    http://www.turtleflock.com/olconfig/index.htm
  and Microsoft Outlook Programming - Jumpstart for
    Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx
 

> Hi,
>
[quoted text clipped - 23 lines]
> Thanks,
> Mani
Mani - 22 Feb 2007 23:34 GMT
Hi Sue,

I have created the custom form with the below public function and I want to
use the public function across many forms.  For example

Public Function GetData(requireElement)
Dim nodes
Dim i
Dim Element()

Set xmldoc = createobject("MSXML.DOMDOCUMENT")
    xmldoc.async="false"
    If xmldoc.Load("\\devdata\Admin\Sample.xml") then
    Else
        Msgbox "Not Loaded..."
    End If

Set nodes=xmlDoc.selectNodes(requireElement)
redim preserve Element(nodes.length-1)

for i = 0 to nodes.length-1
    Element(i)= nodes(i).Text
next

GetData = Element

End Function

Is it possible to call this function from the another form. I have tried the
below code, but getting an error.

Function GetNewItem()
    Dim nameSpace, inbox, newItem
    Set nameSpace = Application.GetNameSpace("MAPI")
    Set inbox = nameSpace.GetDefaultFolder(6)
    Set newItem = inbox.Items.Add("IPM.Note.XMLNavigation")
    Set GetNewItem = newItem
End Function

sub cmdimport_click()
    dim xmldoc
    dim st
    set xmldoc=GetNewItem()
    set st=xmldoc.GetData("A\B\C") ----> Here getting an same error.

end sub

Please suggest me the solution.

Thanks,
Mani

> This may sound obvious, but whatever code you want to run each form to run needs to be present in that form's code editor window.
>
[quoted text clipped - 27 lines]
> > Thanks,
> > Mani
Sue Mosher [MVP-Outlook] - 23 Feb 2007 00:47 GMT
As I indicated earlier, you must copy the function's code into each form you want to use it in.

Signature

Sue Mosher, Outlook MVP
  Author of Configuring Microsoft Outlook 2003
    http://www.turtleflock.com/olconfig/index.htm
  and Microsoft Outlook Programming - Jumpstart for
    Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx
 

>
> I have created the custom form with the below public function and I want to
> use the public function across many forms.  For example

>> This may sound obvious, but whatever code you want to run each form to run needs to be present in that form's code editor window.
>>
>> It's not at all clear from what you posted what xmldoc is supposed to be. If you're calling an external component, you need to instantiate that component first.

>>    
>> > Hi,
[quoted text clipped - 24 lines]
>> > Thanks,
>> > Mani
 
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



©2008 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.