|
You can use WScript.Exec to launch your command window, which will return a WshScriptExec[^] object and give you access to its StdOut and StdIn streams. StdOut is the stream of output from your launched program and StdIn is the keyboard that your code uses to type in the console. You don't need SendKeys at all.
|
|
|
|
|
Thanks for the suggestion about WScript.Exec. I have been trying it out over the last couple of days, initially with not much success, partly due to the fact that I have been unable to find any reasonable documentation on StdOut and StdIn – I could basically only find example bits of code in places like script56.chm and Microsoft Technet, which didn’t work with my application. However after much trial and error, I have basically got it working.
But I couldn’t get StdIn to work at all – it wouldn’t pass keystrokes to my command line program. Hence I have continued to use SendKeys to pass keystrokes to the program, after reading StdOut to determine when to issue the keystrokes. And I have found that I had to introduce a slight delay (Wscript.sleep 100) before issuing the keystrokes – if I didn’t, sometimes it worked and sometimes it didn’t. A disadvantage of Exec compared to Run is that with Exec, the output of the command line program wasn’t displayed in the command window (it is with Run), so I have copied it from StdOut to the window with Wscript.Echo.
Hence I think I have now got the basis for something that should work as I want, although it needs more work. Thanks for your help.
|
|
|
|
|
What is the best way to check for a particulair file in a folder?
e.g. I want to count the number of files that start with say "temp" and have an extension of txt.
In this example
Folder = Temp
Files = temp01.txt, report.txt, temp02.txt.
In this example we would return a count of 2
|
|
|
|
|
Central_IT wrote: What is the best way to ...
Depends on your definition of best.
The easiest way would be based on the Directory.GetFiles(String, String) method, taking the Count of the array being returned. This however is not the least expensive one in terms of system load, as it is building an array of strings, which potentially could be huge and take long.
The cheapest way would probably be based on calling the Win32 functions GetFirstFile() and GetNextFile() , which requires P/Invoke and a bit more code.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
modified on Friday, January 14, 2011 6:27 AM
|
|
|
|
|
Hi All,
I would like to know, how can I detect whether an application is already launched?
I need to enable some function according to this checking, can some people help?
thanks so much.
|
|
|
|
|
The preliminary question is: how do you identify your app?
You could use Process.GetProcessesByName() to check for a specific process name; process names normally get derived from the EXE's file name (which can easily be modified!).
A more reliable approach, if you are the author of the app, is by using a system resource (e.g. a Mutex) with a chosen system-wide name; you then check for the existence of that Mutex. This is how "single instance applications" normally do it. You may want to read this: A Pure .NET Single Instance Application Solution[^] or some similar article.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Thanks for your infomation, Luc.
I'm using your approach, and it works fine.
I just got another question, if the PC is a remote server that different user may login to the server and launching the same application. May I use the same function to detect what specific user is launing the application ?
thanks
|
|
|
|
|
application event:
Private Sub MyApplication_StartupNextInstance(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupNextInstanceEventArgs) Handles Me.StartupNextInstance
End Sub
can that help?
|
|
|
|
|
I have a listview with values
Salary Name Department
2000 Peter Accounts
1000 Anne Sales
If I want the salary, I have the following code that works
MsgBox(lvwListView.SelectedItems(0).Text)
This gives me a value of 2000.
What is the code if I want to display their Name or the Department instead of salary
|
|
|
|
|
Use the SubItems collection of the ListViewItem[^].
I must get a clever new signature for 2011.
|
|
|
|
|
Try changing the selected items to 2
ie
MsgBox(lvwListView.SelectedItems(2).Text)
You should also be able to refer to the name of the field ie
MsgBox(lvwListView.SelectedItems("Department").Text)
Cheers
Ants
|
|
|
|
|
Hi,
I am working Access 2007. I am using subforms as datasheet view. I am embeding this subform to another main form. In main form this subform displays like Gridview, behind this i have some text box control on the main form.
when i am selecting the records from the subform, the respective records will be bounded to the textbox boxes which is on the same form(Main),
The problem is clicking on the cells is perfectly working, but when i click the left side column (default) as soon as i click any cells its not working, the respective record will be the bounded
to the textbox boxes but the respective selected row from the subform is not highlighting instead of highting the same row .
private sub Form_current()
Form_frmFundGroup.Filter = "Id = " & Me![Id]
Form_frmFundGroup.FilterOn = True
end sub
the above code is for subform to bound the data as per the selection on the subform(gridvew)
how to resolve this can u anyone give me suggestion plz...
kannak
|
|
|
|
|
|
Hi,
Is there a VBA technique to search for existence of a range of cells containing certain values and if such range(s) exists severally in a worksheet return an array of these ranges or at least their coordinates?
Regards,
Cyril
|
|
|
|
|
Excel Ranges - Stackoverflow[^]
As barmey as a sack of badgers
Dude, if I knew what I was doing in life, I'd be rich, retired, dating a supermodel and laughing at the rest of you from the sidelines.
|
|
|
|
|
I'm not clear on what you want to search and for what, so perhaps you could clarify. Do you want to search
- a range of cells for a value that fits in one cell and return all the cells containing the value?
- a range of cells for a value that may occur across cells?
- a spreadsheet for a specific sequence of cell vales?
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Or maybe a rectangular range of cells, sized A by B, containing each and every value of another rectangular range of cells, sized C by D, where A*B equals C*D and the order of the matching cells doesn't matter.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
... contains the equivalent words, if translated to Dutch?
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Hi Luc,
What you describe is what I am looking to do, but the order of the matching cells matters. Cell A1 of the range has to be C1 etc...
|
|
|
|
|
Hi Walt,
I think the 3rd is more of what I require. I am formatting reports of a system that dumps in ASCII format, and it places several reports sequentially on one text file. I figured to isolate these reports the best option is to upload into excel and search for the cells that contain the header fields and thus know where each report begins as the report offers no other fields/tags that indicate report start and end. Thus I want to iterate and find all ranges where cell 1 in the range contains value 1, cell 2 contains value 2, cell 3 contains value 3 etc thus indicating where each report begins. A bit messy but seems to be the only way out
Regards
modified on Wednesday, January 12, 2011 1:32 AM
|
|
|
|
|
I am attempting to write a macro so that within an Excel Worksheet I call it, and it saves the .xlsm, saves as a web page and then opens the ftp (in this case filezilla).
I am now stuck.
Where I want to go with this is that the ftpclient automatically opens on the correct website.
(We have several)
After that I am happy to select the files to upload and close.
I have embedded a hyperlink in the file at cell A1.
I suspect that I may need to somehow put the host/username/password into the macro somewhere and get it called on the call of the ftpclient.
Can anybody suggest where I am going wrong?
Sub Macro2()
ActiveWorkbook.SaveAs Filename:="C:\Users\David\Desktop\Book1.xlsm", _
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
Application.DisplayAlerts = False
With ActiveWorkbook.PublishObjects.Add(xlSourceWorkbook, _
"C:\Users\David\Desktop\Book1.htm", , , xlHtmlStatic, "Book1_31795", "")
.Publish (True)
.AutoRepublish = True
Application.DisplayAlerts = True
End With
Application.Left = 161.5
Application.Top = 91.75
Range("a1").Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
End Sub
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC League Table Link
CCC Link[ ^]
|
|
|
|
|
Hoi,
this[^] suggests one can invoke FileZilla client with a specific target website in mind, so if your VBA powers allow you to execute an arbitrary "DOS command", I'd go for it.
Alternatively, you could use a different FTP client, e.g. the one provided by (some versions of?) Windows, see here[^].
I expect those FTP clients will still prompt you for username and password.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
OK, as far as I can tell I need to open a dos shell and call a batch file.
Is that right?
Call the shell as:
Shell ftp.bat",vbnormalfocus
Batch file to look something like:
filezilla ftp://username:password@server:port
As far as I can tell this will open the command shell, then run the batch file ftp.bat which will call FileZilla and apply the necessary data to expose the website.
Is this right?
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC League Table Link
CCC Link[ ^]
|
|
|
|
|
I don't know the details, as I avoid VB6 and VBA as much as possible. I don't think you need a batch file, although it could make sense to have it anyway.
I would read up on, and experiment with, things like this:
Call Shell("cmd /K FileZilla whatever_constant_arguments_you_want_to_provide" & or_variable_arguments, vbNormalFocus)
or maybe simply:
Call Shell("FileZilla whatever_constant_arguments_you_want_to_provide" & or_variable_arguments, vbNormalFocus)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
A word of caution:
Make sure filezilla.exe is in the PATH variable.
Or
You provide absolute path to the filezilla exe
Or
You place the bat file in the correct location with relation to how you have called the filezilla exe.
Shreekar
|
|
|
|
|