Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default vb.net import macro error and allow visual basic is checked in se.

Hello,
I am working on a ASP.NET app written in VB.net. I am attempting to import
an Excel Macro module into an excel workbook.

I am able to run the macro if it is already in the workbook but this
workbook will be created on the fly and this macro needs to be integrated in.

My current code is:

Dim oExcel As Excel.Application
Dim oBook As Excel.Workbook
Dim oBooks As Excel.Workbooks
Dim oModule As VBIDE.VBComponent

exportPath = "c:\Inetpub\wwwRoot\TT\Reports\" &
TTUser.GetUserNameFromID(TTSecurity.GetUserID) & "\"

webPath = "/TT/Reports/" & TTUser.GetUserNameFromID(TTSecurity.GetUserID)
myFileName = webPath & "/Excel.xls"

'Start Excel and open the workbook.
oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
oExcel.DisplayAlerts = False

oBooks = oExcel.Workbooks
oBook = oBooks.Open(exportPath & "Excel.xls")

oBook.Application.VBE.ActiveVBProject.VBComponents .Import(exportPath &
"Module1.bas")

oExcel.Run("ParseData") 'Run the macros.
oBook.SaveAs(exportPath & "Excel.xls") 'Save in a temporary file

Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = myContentType
Response.Redirect(myFileName) 'Send the user to the file
Response.Flush()
Response.Close()

My code bombs on:
oBook.Application.VBE.ActiveVBProject.VBComponents .Import(exportPath &
"Module1.bas")

It gives me this message: System.Runtime.InteropServices.COMException:
Programmatic access to Visual Basic Project is not trusted

Now I have done some research and it has told me to check the box for Trust
access to Visual Basic Project.
I was sure this would solve the problem but I still get the same error.
I am running Windows XP, Excel 2003 and VS.NET 2003.

Any suggestions would be greatly appreciated.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Basic Error Run Time Error, Type Mismatch Meg Partridge Excel Discussion (Misc queries) 12 September 10th 08 06:10 PM
MS Visual Basic error cmar Excel Discussion (Misc queries) 1 June 9th 06 10:29 PM
MS Visual Basic Error...from MAcro G118 Excel Discussion (Misc queries) 0 December 12th 05 05:56 PM
Visual Basic macro run time error(13) type mismatch Paul Excel Discussion (Misc queries) 0 October 25th 05 07:28 AM
Import Excel Forms into Visual Basic? Erik - VB Coder Excel Programming 1 November 24th 04 07:34 PM


All times are GMT +1. The time now is 01:57 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"