|
-
Apr 15th, 2009, 01:46 PM
#1
Thread Starter
New Member
Execute a string
In VBS you can execute a string to run as code.
Here is an example:
Code:
strTest = "msgbox " & chr(34) & "Test." & chr(34)
execute strTest
I am trying to make a AD interface in excel 2007(per a user request).
I would like to make it dynamic in that users can select what attributes they want to see.
So, for example they can enter in cn (which returns the user's name) as one of the attributes they want. A simplified example of what I would like to do is:
Code:
strAttribute = Sheets("Control").Range("a1")
execute "strUserAttribute = objUser." & strAttribute
msgbox strUserAttribute
Since execute isn't part of VBA, how do I do this please?
Thanks,
-Jeremy
Last edited by jelliott; Apr 15th, 2009 at 01:58 PM.
-
Apr 15th, 2009, 03:48 PM
#2
Re: Execute a string
Is this what you are trying to do?
vb Code:
strAttribute = Sheets("Control").Range("a1")
strUserAttribute = objUser & strAttribute
MsgBox strUserAttribute
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Apr 16th, 2009, 12:10 PM
#3
Thread Starter
New Member
Re: Execute a string
 Originally Posted by koolsid
Is this what you are trying to do?
vb Code:
strAttribute = Sheets("Control").Range("a1")
strUserAttribute = objUser & strAttribute
MsgBox strUserAttribute
Unfortunately that is not it.
In your example, if objUser was a variable than that would set the variable strUserAttribute to equal what ever values objUser and strAttribute were textually. For example of objUser had a value of “something” and strAttribute had a value of “cn”, then strUserAttribute would have a value of “somethingcn”.
Since objUser is not a variable and is an object, it just would error out. I am not trying to get the text, objUser.cn, I am trying to get the value that objUser.cn represents. I can just type in the code myself, objUser.cn, but it means that the users off my spreadsheet will not have the freedom of adding any Attribute they like without having to edit the code themselves.
-Jeremy
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|