|
HI,
i am getting error " Word cannot fire events"
Dim oWApp As New Word.Application
oWApp.Application.Visible = True
oWApp.Application.Documents.Add()
oWApp.Selection.TypeText("Hello world")
oWApp.ActiveDocument.SaveAs("f:\vv.doc")
oWApp.Quit()
Regards,
Murali Kumar Pitchika
http://pitchika.page.tl/
http://murali.vndv.com/
Regards,
Murali Kumar Pitchika
http://muralip.f2g.net
|
|
|
|
|
Hiii
First declare object of word like this (With Events) then try.
public Withevents oWapp as new word.application
Thanx
~Khatri Mitesh
|
|
|
|
|
It took me long enough to understand the basic aspects of object orientation, like inheritance, but i still can't seem to wrap my head around what on earth an interface is or what purpose it serves. I've read all the books, and i still can't seem to get it.
if (your.Life == lifestyles.Programming)
{
your.Cool = true;
}
else
{
your.Cool = false;
}
|
|
|
|
|
Does an interface not specify the methods/functions/procedures available in the implementation section, so that you can hide the actual implementation from the users? Is it not a method of abstraction... ie: all you need to know is what to call, how to call it and what it does, you do not need to know exactly how it works.
--------------------------------------------------------
Knowledge is knowing that the tomato is a fruit.
Wisdom is not putting it in fruit salad!!
|
|
|
|
|
An interface is a "contract" that specifies what properties and methods a class must have. Interfaces are commonly used for making a program extensible. This way your program can create and use objects that implement the interface without making them inherit from a specific base class.
Another example use for interfaces is the IEnumerable interface. Anything that implements this interface can be used in for each, LINQ, and data binding. If not for interfaces, these classes would all have to inherit from the same base class. Can you imagine making Array, Stack, List, Dictionary, etc. all share a base Enumerable class?
|
|
|
|
|
Um, thanks for trying to explain it... hate to say i'm still as lost as ever. I'll think about it, see if i can't figure it out.
if (your.Life == lifestyles.Programming)
{
your.Cool = true;
}
else
{
your.Cool = false;
}
|
|
|
|
|
Gideon's answer is correct.
Let's say you want to use a specific interface and that interface has 2 subs and a function:
Public Interface ISomeInterfacehere
Sub AddUser(byval vUser as string)
Sub UpdateUsers
function GetBirthDay(byval vUser as string) as datetime
End Interface
The interface is not providing any code, its just providing method signatures that you need to implement. When you "implement the interface" in your class, you write the code for what you want each sub/function to do.
Public Class TestClass
Implements ISomeInterfacehere
Public sub AddUser(byval vUser as string) As String Implements ISomeInterfacehere.AddUser
'You would add code here to add a user
End Function
Public sub UpdateUsers Implements ISomeInterfacehere.UpdateUsers
'You would add code here to update users
End Function
Public function GetBirthDay(byval vUser as string) as datetime Implements ISomeInterfacehere.GetBirthDay
'You would add code here to return the need birth date.
End Function
End Class
I free handed the example above, but it shows how to create and use the interface.
|
|
|
|
|
Under .net, any class of object is only allowed to 'inherit' from one other class of object. There are sound reasons for this, since multiple inheritance causes considerable complications and confusion.
Nonetheless, there are many circumstances where something resembling multiple inheritance would be desirable. For example, a container control should be inherited from a basic control (obviously), but it should also support a standard method of enumerating its contents, which would suggest that it should be inherited from a 'things whose contents can be enumerated' class. It's not possible to have a container control (or anything else) inherit from more than one class, but it is possible to use interfaces to make it be a 'thing whose contents can be enumerated' in addition to being a control.
The primary differences between inheritance and interfaces are- Classes can be inherited from at most one other class, but can have an unlimited number of interfaces
- A class that inherits another class will by default use the properties, methods, and fields of the base class; there are no "default" implementations for interfaces. If ten classes support an interface, the code for every property or method in the interface must be repeated in all ten classes even if it is identical in every case.
- While it is possible (and often useful) to declare an object variable or parameter as being of an interface type (e.g. "iDisposable") it is not possible to create a new variable of an interface type.
If rather than having "Control" be an inheritable class, .Net were to use an iControl interface, then every type of control would have to include code for dozens of methods and properties; it would be a total nightmare. Inheriting the "Control" class allows controls to use mostly default behaviors and simply implement the things that are unique to each type of control. Since a container control isn't inherited from a container class, it must explicitly implement code to handle enumeration (the iEnumerable interface) but that's far less of a hassle than would be implementing every control property on every control.
|
|
|
|
|
Hi
How do I write the program code to create a button in excel visual basic, can anyone help me?
Sorry if I posted this in the wrong place.
Matt
|
|
|
|
|
In Excel 2003, right click the menu bar and select "Control Toolbar" from the list. Click on a command button and draw one on the screen. Double click the button you drew and you will be taken to the VBA code screen. Enter code there!
--------------------------------------------------------
Knowledge is knowing that the tomato is a fruit.
Wisdom is not putting it in fruit salad!!
|
|
|
|
|
this allows me to create a button to run the script but how do I write code to create the button within a currently running program.
example
I am currently running a script to create a NEW worksheet from scratch and then display certain information based on data the user enters. I want the script to then create a series of button on this NEW worksheet to allow the user to then modify values that they have already entered. As a result I need to hardcode creating the button into initial script, and then add the various code to the button to allow them to update values.
Hopefully this makes sense and someone can help me with my dilema
|
|
|
|
|
Maybe this is what you are looking for...
With ActiveWorkbook.Sheets("SheetName").Buttons.Add(10, 10, 100, 25)
.OnAction = "FunctionName"
.Caption = "New Button"
.Name = "cmdNewButton"
End With
|
|
|
|
|
Cheers exactly what I needed
I have figured out how to create the button, and place on the screen at the desired location, and I have created the script I want the button to perform.
Brief example of my layout
Private Sub Month_Click()
With ActiveWorkbook.Sheets(SetMonth).Buttons.Add(500, 50, 100, 25)
.OnAction = "FunctionName"
.Caption = "Foreign"
.Name = "cmdNewButton"
End With
End Sub
Sub FunctionName()
Amount1 = Application.InputBox("Enter Amount")
Worksheets(SetMonth).Range("A1").Value Amount1
End Sub
The problem is it won't work, any ideas as to what I am doing wrong?
|
|
|
|
|
Is this the exact code you have in your Excel macro? If yes, then you have not assigned Amount1 to Value... I mean, you are missing a "=".
I tried after inserting = and it works for me
|
|
|
|
|
doesn't for me
I get a message saying
The macro 'Finance2.xls!FunctionName' cannot be found.
when I click on the button
|
|
|
|
|
I had both the button creation code and the FunctionName in a module when I tried it out - maybe that is what is needed.
|
|
|
|
|
your a star, you was right.
|
|
|
|
|
I have serveral databases with same tables and different data... I have a Strongly typed Dataset I set up with the Dataset designer wizard which contains a few Datatables & Tableadapters... but it points to one database... Since I have several databases with the same tables I want to use the same dataset and datatables but let the user pick the Database at run time. I'm not sure if you can change the Connection string at runtime for a Tableadapter..... but that is my question can you change the Connection string at runtime for a Tableadapter of a strongly typed dataset.
VB.Net 2005
Thanks in advance
dotnetme2
|
|
|
|
|
You can change the connection string of a tableadapter at runtime by updating the Connection.ConnectionString property.
--------------------------------------------------------
Knowledge is knowing that the tomato is a fruit.
Wisdom is not putting it in fruit salad!!
|
|
|
|
|
Changing the tableadapter's connectstring is the easiest way to do it (IE: we send the conn obj to the dal, which then determines connection string to use).
The dataset also has a InitConnection sub which you could modify to change the connect string as well; but if you modify the DS, the partial class may be rebuilt and your source changes lost.
|
|
|
|
|
I made a dll that is com-wrapped. How do you distribute that dll and register that dll in the registry? I have created a setup program that does it but is there an alternative to the setup program?
Thanks,
Nathan
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
Do you just need to register the dll using regsvr32[^]?
|
|
|
|
|
Thanks for the reply. No. I tried that and it said there was no-entry point into the dll.
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
i think i found it. there is a tlb file that comes along with the dll. there is an application in the windows directory called regtlib.exe that's how you register the tlb file which will auto-link itself back to the dll.
thanks anyway....
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
Ah, thanks for the note. That's worth remembering.
|
|
|
|