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 / July 2003

Tip: Looking for answers? Try searching our database.

Runtime Error 6068 Programmatic Access to Visual Basic Project is not trusted

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Keith Lubell - 31 Jul 2003 14:51 GMT
The following code generates this error:

Dim appWord As New Word.Application
Dim strCodePath As String
strCodePath = "x:\Macro Modules\"

Dim temNorm As Word.Template
Dim strBas As String

Set temNorm = appWord.NormalTemplate

DoEvents
'This loops through all the export mods and imports them into the normal.dot
vbproject
strBas = Dir(strCodePath & "*.bas")
Do Until strBas = ""
   'the dir function doesn't return the path, so we add it here
   strBas = strCodePath & strBas

   '-- FAILS ON IMPORT STATEMENT
   temNorm.VBProject.VBComponents.Import strBas

   DoEvents
   'calling dir with no arguments returns the next file matching the
pattern
   strBas = Dir
Loop

I have reset the macro security on WORD 2002 to LOW and I have checked the
allow access to VB Projects, but after rebooting the machine. It still does
not work. I assume this is to prevent Viruses from affecting the normal.dot,
but I am creating docs for a special mail merge app. I am going to try to
create another template with these injected macros. Any other ideas?
Keith Lubell - 31 Jul 2003 15:47 GMT
I have found that this code now works as long as a document is open! I added
the following code.

Dim docOther As New Word.Document
Dim strBas As String
'Dim myPopup As Office.CommandBarPopup

Set temNorm = appWord.NormalTemplate
If Left(appWord.Version, 2) = "10" Then
   Set docOther = appWord.Documents.Add(newtemplate:=True, Visible:=False)
End If

> The following code generates this error:
>
[quoted text clipped - 29 lines]
> but I am creating docs for a special mail merge app. I am going to try to
> create another template with these injected macros. Any other ideas?
 
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.