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 / Word / Programming / February 2006

Tip: Looking for answers? Try searching our database.

How to insert a VB macro in word doc (programatically)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
shokiegupta@gmail.com - 02 Feb 2006 08:16 GMT
Can anyone please help me with this? I am trying to insert a VB macro
(2 line code) in MS word documnet (programatically!!).

Here is what i am doing:
   Dim odoc As Word.Document
   Set wordApp = New Word.Application
   With wordApp
       Set odoc = .Documents.Open(App.Path & "\sample.doc", , False)
      <something needs to be done here>
       odoc.Save
       odoc.Close
   End With
   Set odoc = Nothing
   Set wordApp = Nothing

So dont know how to insert macro code here in this word document
(programatically).

Any help would be appriciated! Thanks!
Baconbutty - 23 Feb 2006 17:25 GMT
> Can anyone please help me with this? I am trying to insert a VB macro
> (2 line code) in MS word documnet (programatically!!).
[quoted text clipped - 15 lines]
>
> Any help would be appriciated! Thanks

Hi, I am a pure amateur at this (programming is not my day job), so I
am not sure if this helps, but I am currently looking at the VBProject
object.

Accessible from NormalTemplate.VBProject, or ActiveDocument.VBProject.

This seems to offer access to code modules.

I am currently looking at something similar, where I have an external
script that is automating word and programmatically setting up a
toolbar and custom VB procedures.  Not got it working yet.

Regards

Julian Turner
 
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.