I'm trying to use the GetObject Method in VScript to copy information into a
custom Outlook form:

Set objIE = GetObject(,"InternetExplorer.Application")
objIE.Visible = True
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objFolder = objNS.GetDefaultFolder(6)
Set objItem = objFolder.Items.Add("IPM.Post.GenericDocument")
objItem.Display
Set objPage = objItem.GetInspector.ModifiedFormPages("Message")
objPage.Controls("txtURL").Value = objIE.LocationURL
objPage.Controls("Subject").Value = objIE.LocationName
objItem.BodyFormat = 2
objItem.HTMLBody = objIE.Document.Body.innerHTML
Set objItem = Nothing
Set objIE = Nothing
Set objApp = Nothing
Set objNS = Nothing
Set objFolder = Nothing
Set objPage = Nothing

I get an "Unspecified" error is at

objItem.HTMLBody = objIE.Document.Body.innerHTML

but none of the information ends up in the proper fields and, as far as I
can tell, the script is failing to properly assign the objIE object. Could
someone give me a clue as to what might be wrong?

Thanks,
Tom S.

--
Talent hits a target no one else can hit; Genius hits a target no one else
can see.
-- Arthur Schopenhauer

Re: GetObject for IE by Christoph

Christoph
Sun Jun 20 16:09:58 CDT 2004

20.06.2004 17:06, Thomas R. Shannon schrieb:

> I'm trying to use the GetObject Method in VScript to copy information into a
> custom Outlook form:
>
> Set objIE = GetObject(,"InternetExplorer.Application")

Afaik IE can not be 'GetObject'-ed since its instances are not
added to the ROT ('Running Object Table'), which is pre-condition
for GetObject to work.

But you can link to the HTML-Contents of an IE-Instance with the
ShellWindows()-collection.

--
Gruesse, Christoph

Re: GetObject for IE by Thomas

Thomas
Sun Jun 20 21:05:22 CDT 2004

Christoph Basedau wrote:
> 20.06.2004 17:06, Thomas R. Shannon schrieb:
>
>> I'm trying to use the GetObject Method in VScript to copy
>> information into a custom Outlook form:
>>
>> Set objIE = GetObject(,"InternetExplorer.Application")
>
> Afaik IE can not be 'GetObject'-ed since its instances are not
> added to the ROT ('Running Object Table'), which is pre-condition
> for GetObject to work.
>
> But you can link to the HTML-Contents of an IE-Instance with the
> ShellWindows()-collection.

That's fantastic. Thanks. For those who are wondering, here's the code as
it stands. After minimal testing, it seems to work.

Set objShell = CreateObject("Shell.Application")
Set objShellWindows = objShell.Windows
Set objIE = objShellWindows.Item
objIE.Visible = True
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objFolder = objNS.GetDefaultFolder(6)
Set objItem = objFolder.Items.Add("IPM.Post.GenericDocument")
objItem.Display
Set objPage = objItem.GetInspector.ModifiedFormPages("Message")
objPage.Controls("txtURL").Value = objIE.LocationURL
objPage.Controls("Subject").Value = objIE.LocationName
objItem.BodyFormat = 2
objItem.HTMLBody = objIE.Document.Body.innerHTML
Set objItem = Nothing
Set objIE = Nothing
Set objApp = Nothing
Set objNS = Nothing
Set objFolder = Nothing
Set objPage = Nothing

Tom S.
--
The direct use of force is such a poor solution to any problem, it is
generally employed only by small children and large
nations. -- David Friedman



Re: GetObject for IE by Joe

Joe
Mon Jun 21 05:08:04 CDT 2004

Okay, but what if there is more than one instance of IE and/or the file
explorer is open?

Joe

"Thomas R. Shannon" <tshannon@rush.REMOVEME.edu> wrote in message
news:udk22QzVEHA.1036@TK2MSFTNGP12.phx.gbl...
> Christoph Basedau wrote:
>> 20.06.2004 17:06, Thomas R. Shannon schrieb:
>>
>>> I'm trying to use the GetObject Method in VScript to copy
>>> information into a custom Outlook form:
>>>
>>> Set objIE = GetObject(,"InternetExplorer.Application")
>>
>> Afaik IE can not be 'GetObject'-ed since its instances are not
>> added to the ROT ('Running Object Table'), which is pre-condition
>> for GetObject to work.
>>
>> But you can link to the HTML-Contents of an IE-Instance with the
>> ShellWindows()-collection.
>
> That's fantastic. Thanks. For those who are wondering, here's the code
> as
> it stands. After minimal testing, it seems to work.
>
> Set objShell = CreateObject("Shell.Application")
> Set objShellWindows = objShell.Windows
> Set objIE = objShellWindows.Item
> objIE.Visible = True
> Set objApp = CreateObject("Outlook.Application")
> Set objNS = objApp.GetNamespace("MAPI")
> Set objFolder = objNS.GetDefaultFolder(6)
> Set objItem = objFolder.Items.Add("IPM.Post.GenericDocument")
> objItem.Display
> Set objPage = objItem.GetInspector.ModifiedFormPages("Message")
> objPage.Controls("txtURL").Value = objIE.LocationURL
> objPage.Controls("Subject").Value = objIE.LocationName
> objItem.BodyFormat = 2
> objItem.HTMLBody = objIE.Document.Body.innerHTML
> Set objItem = Nothing
> Set objIE = Nothing
> Set objApp = Nothing
> Set objNS = Nothing
> Set objFolder = Nothing
> Set objPage = Nothing
>
> Tom S.
> --
> The direct use of force is such a poor solution to any problem, it is
> generally employed only by small children and large
> nations. -- David Friedman
>
>



Re: GetObject for IE by Thomas

Thomas
Mon Jun 21 08:00:53 CDT 2004

Joe Fawcett wrote:
> Okay, but what if there is more than one instance of IE and/or the
> file explorer is open?

I wasn't really interesting in dealing with that but for what its worth,
there's an optional index paramenter for the Item property that probably
indicates which instance you want to dela with. I usually just kill the
other open windows, myself. The rest are ordinarily just popup ads and
such. One of these days I'll play with the option and see what it does.

Tom S.
--
The direct use of force is such a poor solution to any problem, it is
generally employed only by small children and large
nations. -- David Friedman



Re: GetObject for IE by Thomas

Thomas
Mon Jun 21 08:33:06 CDT 2004

Thomas R. Shannon wrote:
> Joe Fawcett wrote:
>> Okay, but what if there is more than one instance of IE and/or the
>> file explorer is open?
>
> I wasn't really interesting in dealing with that but for what its
> worth, there's an optional index paramenter for the Item property
> that probably indicates which instance you want to dela with. I
> usually just kill the other open windows, myself. The rest are
> ordinarily just popup ads and such. One of these days I'll play with
> the option and see what it does.

I should have mentioned that the script as written seems to insert the data
from the top-most window.

Tom S.
--
The direct use of force is such a poor solution to any problem, it is
generally employed only by small children and large
nations. -- David Friedman