Home All Groups Group Topic Archive Search About
Author
31 Jan 2006 4:57 PM
Don
Can I run a Word Document Macro from within Visual Basic.

If so, can you help or direct me to the documentation.

Thanks
--
Don Mylrea

Author
31 Jan 2006 5:11 PM
Don
I may have found what I need in another post - Thanks.
--
Don Mylrea


Show quoteHide quote
"Don" wrote:

> Can I run a Word Document Macro from within Visual Basic.
>
> If so, can you help or direct me to the documentation.
>
> Thanks
> --
> Don Mylrea
Author
31 Jan 2006 6:50 PM
Paul Clement
On Tue, 31 Jan 2006 08:57:22 -0800, Don <D**@discussions.microsoft.com> wrote:

¤ Can I run a Word Document Macro from within Visual Basic.
¤

Yes, you can:

http://support.microsoft.com/kb/177760/


Paul
~~~~
Microsoft MVP (Visual Basic)
Author
1 Feb 2006 3:44 PM
Don
Thanks Paul

I'll give that a try.
--
Don Mylrea


Show quoteHide quote
"Paul Clement" wrote:

> On Tue, 31 Jan 2006 08:57:22 -0800, Don <D**@discussions.microsoft.com> wrote:
>
> ¤ Can I run a Word Document Macro from within Visual Basic.
> ¤
>
> Yes, you can:
>
> http://support.microsoft.com/kb/177760/
>
>
> Paul
> ~~~~
> Microsoft MVP (Visual Basic)
>
Author
1 Feb 2006 3:50 PM
Don
Paul, Do I have to have Microsoft Word 97 Standard Edition to run the Macros
in Word.
--
Don Mylrea


Show quoteHide quote
"Paul Clement" wrote:

> On Tue, 31 Jan 2006 08:57:22 -0800, Don <D**@discussions.microsoft.com> wrote:
>
> ¤ Can I run a Word Document Macro from within Visual Basic.
> ¤
>
> Yes, you can:
>
> http://support.microsoft.com/kb/177760/
>
>
> Paul
> ~~~~
> Microsoft MVP (Visual Basic)
>
Author
1 Feb 2006 4:04 PM
Ken Halter
"Don" <D**@discussions.microsoft.com> wrote in message
news:0B1DAAD6-9446-4EB8-AA5F-71A5B58155B3@microsoft.com...
> Paul, Do I have to have Microsoft Word 97 Standard Edition to run the
> Macros
> in Word.
> --
> Don Mylrea

From the looks of the code in that article, I'd say..... No. Since it uses
late binding, it should work with any version of Access/Excel/Word

--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Freeware 4 color Gradient Frame? http://www.vbsight.com/GradFrameCTL.htm
Author
2 Feb 2006 3:57 PM
Paul Clement
On Wed, 1 Feb 2006 07:50:04 -0800, Don <D**@discussions.microsoft.com> wrote:

¤ Paul, Do I have to have Microsoft Word 97 Standard Edition to run the Macros
¤ in Word.

Microsoft Word needs to be installed since the process involves automation. I think the example just
refers to Word 97, but any version from Word 97 forward should support this capability.


Paul
~~~~
Microsoft MVP (Visual Basic)
Author
3 Feb 2006 11:45 AM
Don
I have upgraded to Microsoft Office Word 2003 and am having trouble running a
macro from Visual Basic.

My Code is:
        Dim WD As Object
        WD = CreateObject("Word.Application")
        WD.Documents.Open(C:\INSPECTION REPORT\PrintEcreateFiles.doc")       
        WD.Run("Project.Module1.EcreateResidential")

On the WD.Run line I Get the following Error:
  An unhandled exception of type 'System.Runtime.InteropServices.COMException'
  occurred in microsoft.visualbasic.dll


I also tried:
    Dim StrCommand As Object
    Dim MyDoc As String
    StrCommand = "Windword.exe C:\PrintEcreateFiles.doc/mEcreateResidencial"
    MyDoc = Shell(StrCommand.vbMaximizedFocus)

I get the Error:
   An unhandled exception of type 'System.MissingMemberException' occurred in
   microsoft.visualbasic.dll

  Additional information: Public member 'vbMaximizedFocus' on type 'String'
not
  found.


Do I have the Proper Dim Statement for MyDoc?

Can you guys help
--
Don Mylrea


Show quoteHide quote
"Don" wrote:

> Can I run a Word Document Macro from within Visual Basic.
>
> If so, can you help or direct me to the documentation.
>
> Thanks
> --
> Don Mylrea
Author
3 Feb 2006 2:37 PM
Gman
You're using VB.NET rather than VB 'classic' so you might be better off
trying on those newsgroups.

A few suggestions anyway:
(1) WD.Run("Project.Module1.EcreateResidential")
Are you sure that the document has been opened with macros enabled? That
would prevent you running the macro.

(2) MyDoc = Shell(StrCommand.vbMaximizedFocus)
This line should probably be:
MyDoc = Shell(StrCommand, vbMaximizedFocus)

(3) Personally, I wouldn't run a macro from VB (.NET or 6). I would
bring the VBA code into VB. It makes troubleshooting and upgrading your
code a lot easier.

HTH


Don wrote:
Show quoteHide quote
> I have upgraded to Microsoft Office Word 2003 and am having trouble running a
> macro from Visual Basic.
>
> My Code is:
>         Dim WD As Object
>         WD = CreateObject("Word.Application")
>         WD.Documents.Open(C:\INSPECTION REPORT\PrintEcreateFiles.doc")       
>         WD.Run("Project.Module1.EcreateResidential")
>
> On the WD.Run line I Get the following Error:
>   An unhandled exception of type 'System.Runtime.InteropServices.COMException'
>   occurred in microsoft.visualbasic.dll
>
>
> I also tried:
>     Dim StrCommand As Object
>     Dim MyDoc As String
>     StrCommand = "Windword.exe C:\PrintEcreateFiles.doc/mEcreateResidencial"
>     MyDoc = Shell(StrCommand.vbMaximizedFocus)
>
> I get the Error:
>    An unhandled exception of type 'System.MissingMemberException' occurred in
>    microsoft.visualbasic.dll
>
>   Additional information: Public member 'vbMaximizedFocus' on type 'String'
> not
>   found.
>
>
> Do I have the Proper Dim Statement for MyDoc?
>
> Can you guys help
Author
3 Feb 2006 3:43 PM
Don
Thanks I'll try.
--
Don Mylrea


Show quoteHide quote
"Gman" wrote:

> You're using VB.NET rather than VB 'classic' so you might be better off
> trying on those newsgroups.
>
> A few suggestions anyway:
> (1) WD.Run("Project.Module1.EcreateResidential")
> Are you sure that the document has been opened with macros enabled? That
> would prevent you running the macro.
>
> (2) MyDoc = Shell(StrCommand.vbMaximizedFocus)
> This line should probably be:
> MyDoc = Shell(StrCommand, vbMaximizedFocus)
>
> (3) Personally, I wouldn't run a macro from VB (.NET or 6). I would
> bring the VBA code into VB. It makes troubleshooting and upgrading your
> code a lot easier.
>
> HTH
>
>
> Don wrote:
> > I have upgraded to Microsoft Office Word 2003 and am having trouble running a
> > macro from Visual Basic.
> >
> > My Code is:
> >         Dim WD As Object
> >         WD = CreateObject("Word.Application")
> >         WD.Documents.Open(C:\INSPECTION REPORT\PrintEcreateFiles.doc")       
> >         WD.Run("Project.Module1.EcreateResidential")
> >
> > On the WD.Run line I Get the following Error:
> >   An unhandled exception of type 'System.Runtime.InteropServices.COMException'
> >   occurred in microsoft.visualbasic.dll
> >
> >
> > I also tried:
> >     Dim StrCommand As Object
> >     Dim MyDoc As String
> >     StrCommand = "Windword.exe C:\PrintEcreateFiles.doc/mEcreateResidencial"
> >     MyDoc = Shell(StrCommand.vbMaximizedFocus)
> >
> > I get the Error:
> >    An unhandled exception of type 'System.MissingMemberException' occurred in
> >    microsoft.visualbasic.dll
> >
> >   Additional information: Public member 'vbMaximizedFocus' on type 'String'
> > not
> >   found.
> >
> >
> > Do I have the Proper Dim Statement for MyDoc?
> >
> > Can you guys help
>
Author
16 Feb 2006 4:33 PM
Lance Collister
*** Sent via Developersdex http://www.developersdex.com ***