User Profile
Collapse
-
Run an Excel Macro from VB
I am using Visual Studio 2005 and need to run a macro from code. Any Ideas on how to do this? -
I was calling my batches via the code below
Dim shell
shell = CreateObject("w script.shell")
shell.run(batch path)
shell = Nothing
This seems to be a more DOS approach but I liked it because it opened each batch in a different dos window which was good for debugging with what I'm doing but this has trouble reading file names with spaces. The following code does not but runs all batches... -
-
Can I grab the SFN(8.3) filename from an existing file.
I am trying to run some batches through VB and when I try to run them through shell it cannot find them but I changed one of filenames to its short file name and it worked. So I want to be able to run a file as its short file name without having to look it up in Dos and change it manually.
-John -
I was able to run the files in my program files folder and on a application server. But I could not run them in the my documents folder or shared servers.Leave a comment:
-
Thanks I was thinking about just having it echo and create a textfile as the last line in the batch. I guess just a less advanced way of doing the same thing but being able to have like a If batch.done = True would be a lot better. So if anyone else nows something similar to that please let me know...Leave a comment:
-
Can you tell when a Batch File is Finished Running
If I execute a Batch File can I check if it is still running through code? -
Well it seems that the folder I was trying to run the batch files from wasn't allowed to execute files. This is weird because our IT Tech gave me specific permissions to execute everywhere but whatever I just moved all my files to a folder where they run all there applications and I was able to execute the files there. I found this out by trying to execute from my local Documents folder (didn't work) but when I moved it to my programs folder it...Leave a comment:
-
I have and just did again and it still doesn't work. This I would say baffles me the most because I could understand if I was using an array and grabbing the filenames from the System.IO.Direc tory.GetFiles() command (which I am) and passing them to the Shell that maybe theres like garbage whitespace or something else messing up the path but when I put in for testing Shell("S:\TestF ile\batch1.bat" ) and it still states the file is not found...Leave a comment:
-
Are you saying to just hard code the batch file path in my code to test it? I don't really understand or are you just saying copy and paste the path and then the file name so you're sure its right?...Leave a comment:
-
I did paste the path in Run and It worked just fine. I originally didn't have a method to run a batch but i just wrote this one up so its easy to post the code.
Public Sub RunBatch(ByVal BatchPath As String)
Shell(BatchPath )
End Sub
It still states that the file is not found...Leave a comment:
-
Yes "J:\Example\Ano ther folder\batch1.b at"
When put in the shell it doesn't work but when followed through explorer it runs the batch...Leave a comment:
-
I am trying to execute a .bat file and the error I am getting for BAT/EXE is file not found. When I take the same path that my program passes to the shell command and debug.print it and copy it to a explorer window it will execute the .bat....Leave a comment:
-
See its not that Shell doesn't open .bat its that it won't find a .exe either. I just frustrated that It has worked in the past (yesterday Morning) and not nowLeave a comment:
-
I literally was opening batch files yesterday with it. If this happens to be the case though how would I go about opening .bat files....Leave a comment:
-
-
Shell Command did work fine but doesn't now.
I am using VB 2005 Express and have used the Shell("Full Path") command before and had it work fine. For some reason I added some code (Un-related to the Shell) it stopped being able to find the file It was previously finding fine. I've had this problem before and eventually gave up and rewrote my code and it worked but is there any way this is a configuration problem or something wrong with the box I'm writing the code on? I usually... -
Awesome I got it! My final code is:
Private Sub Command1_Click( )
MsgBox GetTargetPath(" ShortCut Filename")
End Sub
Private Function GetTargetPath(B yVal FileName As String)
Dim Obj As Object
Obj = CreateObject("W Script.Shell")
Dim Shortcut As Object
Shortcut...Leave a comment:
-
I really appreciate all the help. I am receiving this error when I debug at the line
GetTargetPath = Shortcut.Target PathShortcut.Sa ve
Public member 'TargetPathShor tcut' on type 'IWshShortcut' not found....Leave a comment:
-
It states that Type ObjectSet is not defined. How do I fix that?...Leave a comment:
No activity results to display
Show More
Leave a comment: