Hi All,

While running the below code for excel macro i go the error " Programmatic
access to VB project is not trusted"

Set XLHandle =  CreateObject("Excel.Application")
XLHandle.DisplayAlerts = False
Set XLBook = XLHandle.WorkBooks.Open("c:\temp\1.xls")
Set objCodeModule = XLBook.VBProject.VBComponents.Item("Module1").CodeModule
sNewCode = "Public Function NewFunction(ByVal intStartRow, ByVal intEndRow)"
 & vbCrLf
sNewCode = sNewCode &" Sheet1.Range(Sheet1.Cells(intStartRow, 1),
Sheet1.Cells(intEndRow, 10)).Select" & vbCrLf
sNewCode = sNewCode &" Selection.Interior.ColorIndex = 35" & vbCrLf
sNewCode = sNewCode &"End Function" & vbCrLf
objCodeModule.AddFromString(sNewCode)
XLBook.Save
XLBook.Close
XLHandle.Quit
Set objCodeModule = Nothing
Set XLBook = Nothing
Set XLHandle = Nothing

Please give workaround for this error


Regards,
Udhay

-- 
-- 
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en

--- 
You received this message because you are subscribed to the Google Groups "QTP 
- HP Quick Test Professional - Automated Software Testing" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to