|
using vb.net (any version) I am creating an instance of "excel". Now after completing the process the excel does not close the Process . What I want is to get the ProcessID of "Excel" object created inside my application. so that I can close it. I cannot blindly close all the excel running in the process list as Other users are connected to my machine and they might be running excel as well.
Any Suggestions ??
|
|
|
|
|
I'm not sure if this is possible without any neat tricks, but on top of my head I'm thinking why not save a list of all excel instances before creating the object, and compare it with a new list after creating the object, the difference should be your excel instance.
code might look like this
Dim proc As New List(Of Integer)
For Each p As Process In Process.GetProcessesByName("Excel")
proc.Add(p.Id)
Next
'Create your Excel object here
For Each p As Process In Process.GetProcessesByName("Excel")
If Not proc.Contains(p.Id) Then MsgBox(p.ProcessName) ' This is your instance
Next
of course if your using vb prior to .net 2.0 you can do the same thing with arrays, although more coding will be involved.
|
|
|
|
|
thanks but this will close the excel run by other users.
The problem is my application is running on server and excel object is created on server. so at a time there could be more then 1 excel objects in the list. now which one is the process initiated by my thread is the question. In system all the threads are started by userName="SYSTEM" so I cannot even differentiate with this. if there is any way to get the processID through object variable then it can resolve the problem .. any comments ?
|
|
|
|
|
Unless what I've written below is correct, i don't think i really understand what you want to accomplish.
If your created object starts a new excel process then you will have a new PID which you can save until you finish using the object and then kill the process with the PID.
If your new object gets created inside another existing Excel process, the process may hold other users objects as well and therefore you shouldn't kill it, unless your application manages the object list, and you know for sure that all objects are closed.
|
|
|
|
|
Your code will give an approximate result not the exact result. Just imagine since this is a network application and more then 30 people will be accessing this at the same time. so if any of two people will start the process at the same time then it will be the issue as in new comaprison I shall get the ID which could be inititad by other user. What I was looking for to get some thing exact like I created an object
Dim objExcel as excel.xxxx
then with the help of objExcel I should be able to get the process ID. I tried Hwnd and Hprocess in the objExcel list but these are not process ID.
|
|
|
|
|
Interesting though, i just tried the code below and it worked great.
I know its VBScript but the concept is the same.
Dim xls
Set xls = CreateObject("Excel.Application")
with xls
.Application.Visible = False
.Workbooks.Add
.Sheets("Sheet1").Select
.ActiveSheet.Cells(1,1).Value = "Hello"
.Sheets("Sheet1").SaveAs("hello.xls")
.Application.Quit
End With
Set xls = Nothing
|
|
|
|
|
Hi.
I'm repeating this question so please excuse me. I really need an answer.
I need to set properties of the Ricoh multi-function printer to have default color set to 'black & white' when user logs into the machine (printer is on a network) using some script (VB or anything else). If it is, and the program/script can be created I will call it from a batch file, which runs every time user logs in.
Is there anyway I can use VB.NET or any other languages to set Color to 'black & white' by default for that printer. Anyone's help, who had any experience with this, will be appreciated.
Thank you in advance.
|
|
|
|
|
I have a few ideas but by-no-means a definate answer.
1. Look to the Ricoh company for a solution. Either there website or contacting them.
2. Look into the DLLs that are installed with the printer and try to compose a hack of some-sort that will allow you to change the property.
Not what your looking for but might help you get started.
|
|
|
|
|
Thank you. I was thinking the same way. I was asked to do that this way by our networking guys but it made no sense to me. We are using Citrix that means everyone shares the driver. Even if I create code it will only work for the first person signed in. Everybody else will use his last settings and if he changes it to color everyone will be printing color. Finding out the config file and setting black and white as a defatult and when making config read only makes more sense.
Thank you very much for reply.
|
|
|
|
|
I have successfully create a windows service application and installer in Visual Studio 2005. I would like the service to be installed as a windows user. My current installer does this by setting the Service Process Installer Account to user. However during the installation a popup box appears that looks very out of place with my installation package. Does anyone know how I can create a custom interface within the installer that will allow me to enter the account information and the pass this informatio to the installer class so this pop up does not appear.
Thanks in advance.
Steve Borman (Losing my hair with frustration)
|
|
|
|
|
In my current project there is a requirement of console applications to0 be used with window services in order to process xml files.
I don’t know much about console application. I want to know what is the use of console application ? How we can use it with window services? Or can we build window services through console applications?
|
|
|
|
|
1) what is it: it's basically a DOS enabled windows application with no gui front end to it. it opens a dos window and through code you can, for example, interact with the user via dos...asking questions in the dos window.
Rough explanation I know...
2) how can it be used: I assume the requirement is that the console application is supposed to process the xml file and then the window service is supposed to use the results? if the assumption is correct, you don't have to use a console app to do it. you can put a file watcher inside the windows service and have it look at a specific directory and when a file appears process it under the thread of the event of the watcher.
|
|
|
|
|
i want to copy one database to another using following approach:-
fill dataset1 from adapter1
copy dataset1 to dataset2
update database from dataset2 using adapter2.
But error here is:- Update unable to find TableMapping['Table'] or
DataTable 'Table'.
On Following line:- adapter.Update(ds2)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
LoadFBGrid()
loadDS2()
copyds1to2()
End Sub
Public Sub copyds1to2()
Dim cmdBuilder As FbCommandBuilder = New FbCommandBuilder(adapter2)
ds2 = ds.Copy
adapter.Update(ds2)
End Sub
Public Sub loadDS2()
Try
ds2 = New DataSet("Destination")
con2 = New FbConnection(connectionString2)
con2.Open()
adapter2 = New FbDataAdapter("Select * from Students", con2)
adapter2.Fill(ds2, "Studets")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Public Sub LoadFBGrid()
Try
ds = New DataSet("Source")
con = New FbConnection(connectionString)
con.Open()
adapter = New FbDataAdapter("Select * from Students", con)
dt = New DataTable("Students")
adapter.Fill(ds, "Studets") ' copy ds change
adapter.Fill(dt)
DataGrid1.DataSource = dt
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
"You can do any thing you set to your mind" - theGhost_k8
|
|
|
|
|
Kedar V wrote: Dim cmdBuilder As FbCommandBuilder = New FbCommandBuilder(adapter2)
add this after the above code.
With adapter2
.UpdateCommand = cmdBuilder.GetUpdateCommand()
.DeleteCommand = cmdBuilder.GetDeleteCommand()
.InsertCommand = cmdBuilder.GetInsertCommand()
End With
|
|
|
|
|
This error show-up after PASTING UR CODE:-
An unhandled exception of type 'System.InvalidOperationException' occurred in firebirdsql.data.firebird.dll
Additional information: Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information.
And I DONT WANT TO HAVE ANY KEY COLUMN, UNLESS THATS MUST !!! THANKS AGAIN.
"You can do any thing you set to your mind" - theGhost_k8
|
|
|
|
|
First off, let me just say that this question is just for information purposes. (I'm kinda curious as to why this is happening)
I have a wierd error with the VB program I have access to here.
The error is in the code and has to do with some of the standard tabControl methods.
What happens is that if that there is a method that returns an in depending on what letter is put into it. The returned int is then used to select which tab page is shown by the control.
To get the code to work it goes something like this:
Dim index As New Integer
tabIndex = Groups.ConvertToNumber(Attribute.Group)
If Not Groups.ConvertToNumber(Attribute.Group) = -1 Then
FunctionPicker.SelectedTab = FunctionPicker.TabPages(tabIndex)
End If
The above code works. However if I change the code to this:
If Not Groups.ConvertToNumber(Attribute.Group) = -1 Then
FunctionPicker.SelectedTab = FunctionPicker.TabPages(Groups.ConvertToNumber(Attribute.Group))
End If
It no longer works, when it should. (And as far as I know worked in previous versions)
Any idea as to why this happens?
- Munty
|
|
|
|
|
Disregard previous reply if you saw it... Eyes playing tricks on me.
Don't know.
But here's my 2 cents.
We don't really know what ".ConvertToNumber" returns. We're assuming it's a user-written function and returns something numeric, but...
But the whole thing becomes moot if the code is written properly.
Suggestion: To make the code more efficient, don't execute the expensive function more than once if you can help it.
Execute it, get the validated results in tabIndex, (preferably within a Try block, using System.Convert), so you know exactly what you're dealing with, and then just use the index.
Dave
|
|
|
|
|
Hi there.
The ConvertToNumber always returns a number. The number returned will always be from between -1 and 7. (-1 being the Error number)
I've been stepping through the program with Visual Studios debugger, So I can tell ya that it is definately returning a number. For the testing I was doing, it always returned the number 2. However if I looked at the FunctionPicker.SelectedTab it always states that it contains nothing.
But it always works correctly if I put it into an pass the results of ConvertToNumber into an integer before passing it into the TabPages method.
Hence why I'm calling it a wierd bug
- Munty
|
|
|
|
|
That is definitely a puzzler. If I get some time later tonight I will set one up and see if I can reproduce it.
Dave
|
|
|
|
|
Munty -
Couldn't reproduce it.
I set up a form with a tab control with 8 pages, various overloaded functions to return integers and singles (which I then cast to Int) etc, buttons to set the preconditions and call each scenario, ...
Got the right tab selected every time.
You're right. That's a weird bug.
|
|
|
|
|
I am doing a page for user to editing the information. Before the user click a "SAVE" button, I need to check the time stamp from the database to check whether there is person editing the information before the user. If yes, then I need to pop up a window to show the difference the information.
Please kindly assist.
Thanks
|
|
|
|
|
create a form for the pop up window (frmPopUp)
put the controls that u need in it (labels, textboxes, images,...)
Then
<br />
dim objPopUp as new frmPopUp<br />
objPopUp.(what u need to initialize ...) = ...<br />
objpopUp.show/showdialog 'Depending on how u want it to act (modal,modaless)<br />
hope this would help
Best Regards
3ala2
|
|
|
|
|
I don't have a method of objpopUp.show. May be it is due to I am creating a web form. I still cannot pop up a new window.... But anyway, thanks for 3ala2.
Pls kindly help.
Many Many Thanks
|
|
|
|
|
u should have posted this in the ASP.net section. I gave u windows application code
for pop ups in web u need to use window.open javascript function
Best Regards
3ala2
|
|
|
|
|