View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Hammas Hammas is offline
external usenet poster
 
Posts: 1
Default Run/Execute string expression


I would greatly appreciate any ones help on this one.

I would like to run/execute code that is stored as a sting in excel, I
think I have part of the problem solved.... I can get the following
piece of code to work using a function eval (from mircosoft access 9.0
object library)

------------------------------------------------------------------------------
Sub test()
Dim codetest As String
codetest = "msgbox(""HELLO"")"
eval codetest
End Sub
------------------------------------------------------------------------------
.......but when I try and use it on an excel object like this
snippet of pivottable code then...
------------------------------------------------------------------------------
dim codetest as string
codetest =
("ActiveSheet.PivotTables(""PivotSpend"").AddField s(""Spend"")")
eval codetest
------------------------------------------------------------------------------

....I get this error
MIRCOSOFT ACCESS CAN'T FIND THE NAME ACTIVESHEET YOU ENTERED IN THE
EXPRESSION.

Any ideas on how I can get it to work?? Or is there another way to
solve this problem...

Thanks :) :)


--
Hammas
------------------------------------------------------------------------
Hammas's Profile: http://www.excelforum.com/member.php...o&userid=27642
View this thread: http://www.excelforum.com/showthread...hreadid=471651