Why CreateObject() fails in DevStudio Macro? 
Author Message
 Why CreateObject() fails in DevStudio Macro?

Hi all,

    I have a question regarding DevStudio macros. Why does the following
code:

   Dim item_name
   item_name = ActiveDocument.Selection.Text

   Dim GuidGenerator
   Set GuidGenerator = CreateObject("IS.Component1")

   Dim guid
   guid = GuidGenerator.NewGUID()

   fails? I've tried the code inside VB and Windows Scripting Host, and it
works fine. But with DevStudio macros, it always fails. Or is it just an
impossible thing to do? Is there any technical limitations on doing this
with DevStudio macro? I use Visual C++ 6.0

Thanks.

--
Frederick J. Dunhill
To reply via e-mail, replace coldmail.org with hotmail.com

"Before order there is chaos. Before happiness there is sorrow. Before life
there is death. Like a phoenix bird it vanishes, like a phoenix bird it
resurrects."



Thu, 03 May 2001 03:00:00 GMT  
 Why CreateObject() fails in DevStudio Macro?
I tried running your macro below in VC++ and I am getting the same error.
For grins, I changed IS.Component1 to Excel.Sheet and the same error occurs.
I am guessing that there are limitations to the CreateObject call under VC++
but I do not know exactly what those limitations are.  BTW...what is
IS.Component1?

--
J. Keith Wedinger
Technical Specialist - The Limited, Inc.

http://www.serve.com/uccats

Quote:

>Hi all,

>    I have a question regarding DevStudio macros. Why does the following
>code:

>   Dim item_name
>   item_name = ActiveDocument.Selection.Text

>   Dim GuidGenerator
>   Set GuidGenerator = CreateObject("IS.Component1")

>   Dim guid
>   guid = GuidGenerator.NewGUID()

>   fails? I've tried the code inside VB and Windows Scripting Host, and it
>works fine. But with DevStudio macros, it always fails. Or is it just an
>impossible thing to do? Is there any technical limitations on doing this
>with DevStudio macro? I use Visual C++ 6.0

>Thanks.

>--
>Frederick J. Dunhill
>To reply via e-mail, replace coldmail.org with hotmail.com

>"Before order there is chaos. Before happiness there is sorrow. Before life
>there is death. Like a phoenix bird it vanishes, like a phoenix bird it
>resurrects."



Fri, 04 May 2001 03:00:00 GMT  
 Why CreateObject() fails in DevStudio Macro?

Quote:
>I tried running your macro below in VC++ and I am getting the same error.
>For grins, I changed IS.Component1 to Excel.Sheet and the same error
occurs.
>I am guessing that there are limitations to the CreateObject call under
VC++
>but I do not know exactly what those limitations are.  BTW...what is
>IS.Component1?

IS.Component1 is a simple component that I wrote to access Windows API from
DevStudio macro. And what makes me really confused is that at
http://www.vcdj.com there is an article about this very subject, that is,
the author states that he can access Windows API by creating a wrapper
component and using it via CreateObject() within the VBScript macro. And
certainly he wouldn't submit the article if he hadn't fixed the problem,
right? But he doesn't say anything about CreateObject() failing without
obvious reason, which confuses me a lot.

Or, horror of horrors, it works under VC 5 but not under VC 6? Anyone can
confirm this?

And something very strange is going on here, Keith. Try observing the
running processes with Task Manager, while running the previous macro,
replacing IS.Component1 with Word.Application. It will fail, but winword.exe
is started. Strange, isn't it?

--
Frederick J. Dunhill
To reply via e-mail, replace coldmail.org with hotmail.com

"Before order there is chaos. Before happiness there is sorrow. Before life
there is death. Like a phoenix bird it vanishes, like a phoenix bird it
resurrects."



Sat, 05 May 2001 03:00:00 GMT  
 Why CreateObject() fails in DevStudio Macro?
Frederick,

There is a knowledge base article Q194843 which may help you with this
question.  The article is about the
fact that CreateObject() sometimes succeeds in Visual Studio Macros instead
of failing
which is what it is supposed to do (apparently).

Regards,

Jason.

Quote:

>Hi all,

>    I have a question regarding DevStudio macros. Why does the following
>code:

>   Dim item_name
>   item_name = ActiveDocument.Selection.Text

>   Dim GuidGenerator
>   Set GuidGenerator = CreateObject("IS.Component1")

<snipped>


Tue, 08 May 2001 03:00:00 GMT  
 Why CreateObject() fails in DevStudio Macro?
From my experience, the reason that CreateObject fails for some objects is
because the object is not marked as safe for scripting.

I dont have the URL right now but you can find the registry setting that you
need to change in order to make it safe for scripting on the
http://www.microsoft.com/visualc whitepapers or technical articles.

Quote:

>Hi all,

>    I have a question regarding DevStudio macros. Why does the following
>code:

>   Dim item_name
>   item_name = ActiveDocument.Selection.Text

>   Dim GuidGenerator
>   Set GuidGenerator = CreateObject("IS.Component1")

>   Dim guid
>   guid = GuidGenerator.NewGUID()

>   fails? I've tried the code inside VB and Windows Scripting Host, and it
>works fine. But with DevStudio macros, it always fails. Or is it just an
>impossible thing to do? Is there any technical limitations on doing this
>with DevStudio macro? I use Visual C++ 6.0

>Thanks.

>--
>Frederick J. Dunhill
>To reply via e-mail, replace coldmail.org with hotmail.com

>"Before order there is chaos. Before happiness there is sorrow. Before life
>there is death. Like a phoenix bird it vanishes, like a phoenix bird it
>resurrects."



Wed, 09 May 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Why CreateObject() fails in DevStudio Macro?

2. Can I do CreateObject from inside DevStudio macro files

3. Why New works and CreateObject fails ???

4. Why does this ASSERT_ISKINDOF macro fail?

5. Can I CreateObject in VC++ macro feature ?

6. CreateObject in VC++ macro

7. wsh: CreateObject fails with prefix...

8. Creating complicated DevStudio macros

9. DevStudio Macro Terminator: msdev.exe - Application Error

10. VC6 DevStudio Macro files have Incorrect Icon Association

11. Devstudio 5/6 cant create shell object in macro

12. DevStudio Macros

 

 
Powered by phpBB® Forum Software