#1
|
|||
|
|||
Importing .frm and .bas files using code
Hi,
i'm trying to make a word document that when opened installs (imports) the macros into the computer, but i've been trying to use the code bellow and kept getting the error "Method 'Import' of object'_VBComponents failed". could you help me out, please? i've wanted to do this from Excel as i have other installs there as well and it would've been easier to do it from only one file, but it doesn't work. code: ActiveDocument.VBProject.VBComponents.Import Environ("SystemDrive") & Environ("HomePath") &........... thanks in advance! |
#2
|
|||
|
|||
Must be your path statement
This works for a module in the active documents parent folder: Code:
Sub Document_New() ActiveDocument.VBProject.VBComponents.Import ThisDocument.Path & "\Module1.bas" End Sub |
#3
|
|||
|
|||
the parent file (word or excel doc) will be stored in different locations on different computers while the .frm and .bas files will be downloaded (using the code from the excel doc) in a specific location on every computer. i've entered the code for finding the path of the .frm and .bas files but i don't think that's the problem. thanks!
|
#4
|
|||
|
|||
Does the user application Trust Center settings have "Trust access to VBA project object model" checked?
|
#5
|
||||
|
||||
You cannot access the VBA environment programmatically (e.g. import VBA modules, forms, etc.) unless you give trusted access to the VBA project object model. Every user who is supposed to use the procedure would have to enable that access manually, as it cannot be granted programmatically. Giving trusted access to the VBA project object model on even one PC renders every PC on the network susceptible to macro viruses and is not to be recommended except for the very brief period such access is actually required.
I suggest you rethink whatever it is you're trying to achieve.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#6
|
|||
|
|||
there was a problem with my .frm and .bas files. it works now. thank you!
|
Tags |
auto install, install from excel, word macros |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Importing Pub files into another Pub document | drlynda | Publisher | 0 | 11-20-2014 02:02 PM |
Importing .msg files into another PC ? | bill123 | Office | 2 | 08-15-2011 09:47 AM |
Is there any way of importing Indicators field through code? | Prabhakar | Project | 0 | 04-07-2011 05:50 AM |
Importing many vcf files in excel | shiflerg | Excel | 0 | 01-26-2011 09:16 AM |
Importing CSV files into Oulook | victoria61485 | Outlook | 5 | 12-03-2010 05:33 AM |