PDA

View Full Version : My own little control panel



joelsoh
11-29-2008, 07:57 PM
Ok, I've created a little userform which uses the Shell command to open various programs from buttons. I can open various programs and such from this interface and I think it's pretty cool :P

Anyway I have a few questions that perhaps you guys can help me out with.

1. I have a tabbed interface, one which I've labelled text dump. It has a textbox where I can throw random text in. The problem is, hitting enter in this textbox, doesn't bring me to the next line. Instead it brings the focus onto the tabs again. How do I fix this?

2. The shell command doesn't seem to open non-programs. Is there a command for it? Syntax please :)

3. Is there a way to shut down the computer using VBA? I want to create a button which simply shuts the computer down or makes it sleep

4. Is there a way to open the userform only upon startup? (and not MS Word)? It would be good to have this pop open onto the desktop or something as soon the computer starts up

5. Using Ctrl+Tab to scroll through the tabbed interface works until I hit my textdump tab. The focus automatically hits the textbox and Ctrl+Tab stops working. Possible solutions?

Thanks all.
Yes, it seems like alot hahah sorry :P

Ischyros
11-29-2008, 09:11 PM
Hey I hope this information helps....

1: In the userform, select the text box you are using called "text dump". In the properties window for that text box set the MultLine property to "True" and then set the EnterKeyBehavior to "True" as well. This should fix issue one

2: I am not sure, but I believe the shell function only works with executable files (e.g. word.exe)

3: I believe you can use the command prompt to shutdown your computer. You can start the command prompt using VBA (shell cmd.exe) and then use "send keys" to send this line of code to the command prompt "shutdown -s". You might have to read up on "send keys".

4: I don't think this is possible, but I am not sure. If you are just creating a small little control panel program I would recommend skipping the VBA stuff and go the MSDN and download VB express for free and write it in this. Its a little different since you are making a simple stand alone program, but seems to be a better for fit for what you are doing.

5:There is a TabIndex property you can play with, that might fix the problem. If that is not the issue can you be more desciptive about the problem?


Hope this helps......someone with more experience might be able to better answer 2 and 4. Good Luck!

joelsoh
11-29-2008, 09:24 PM
Ischyros
Thanks for solving number 1. It's helped a lot. :rotlaugh:It also accidentally helped to solve 5 too. Playing around works sometimes with programming :P

I guess I may take a look at VB Express. Thanks!

TonyJollans
11-30-2008, 01:45 AM
This doesn't seem like something that you really want to be doing from inside Word, but ...

2. I think not, but what exactly do you mean by opening non-programs?

4. No. VBA is VB for Applications. It requires a parent Application - not necessarily Word, but some application (that supports it).

fumei
12-01-2008, 01:55 PM
Excellent replies.

RE: #2 "non-programs". I too am rather curious as to what you mean by that. In any case, a quick peek at Help - the magic F1 key.... - regarding Shell, and you can see:

"Runs an executable program and returns a Variant (Double) representing the program's task ID if successful, otherwise it returns zero."

And there ya go.

joelsoh
12-01-2008, 10:22 PM
fumei
hehehe... Um I simply assume anything ending in exe as a program. I'm sure it's wrong after your reaction, but I'm definitely no expert >< I'm sure there's a whole other level of computing I'm not aware.

fumei
12-02-2008, 01:02 AM
Ummm, generally speaking, you are correct. If it has an extension of .exe, then it is executable. Certainly Windows will treat it as such and try and load it - using Shell if that is what you are doing.

And so, yes, anything with an .exe extension is executable, and will fire using Shell.

Are you stating that you have a .exe that does not execute with Shell?

So again, what do you mean by "non-programs"??????

BTW: make sure you understand the difference between shell.exe - which is a dangerous virus enabling executable - and the Shell function - Shell().

The Shell function is a normal part of the OS, shell.exe is bad news.