|
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.
|
|
|
|
|
Using VB code I am looking for a way to save an Excel sheet without getting a prompt (in Excel asking if I want to overwrite the file) and close the Excel without user intervention.
I have created an Excel.application object (MyExcel), a book object (MyBook) and a sheet object
(MySheet)
Through code I dump my datagrid data to the Excel Sheet, and save the file to disk using
MyBook.SaveAs (save_Path & Save_Name)
MyExcel.activeworkbook.close true
This works great if the file does not exist, but prompts me to overwrite the file if it does.
Any Suggestions would be helpful
|
|
|
|
|
Two things you can do...
- delete file first, if it already exists
- set DisplayAlerts to False in MyExcel object
HTH
|
|
|
|
|
Thanks for the advice
"MyCxcel.DisplayAlerts = False" did the trick
|
|
|
|
|
New_Coder wrote: Thanks for the advice
"MyCxcel.DisplayAlerts = False" did the trick
Glad it worked out for you... you are welcome.
|
|
|
|
|
hai all,
i am using .net 2005.i do my project in vb.net windows application.i have 2 listbox named as connolistbox and lotnolistbox.
i displayed the lotnos datas automatically in lotnolistbox based on i selected conno in connolistbox.
i want to do like,
if i removed all lotnos from lotnolistbox means that selected conno from connolistbox must be automatically removed.
for example,
i click 'conno101' in connolistbox means the 4 datas are lotno1,lotno2,lotno3,lotno4 are automatically displayed in lotnolistbox.
then i remove 4 datas are lotno1,lotno2,lotno3,lotno4.
now lotnolistbox is clear.when lotnolistbox clear means the 'conno101' must be automatically removed from connolistbox.
if lotnolistbox not clear means the 'conno101' must be there in connolistbox.
|
|
|
|
|
he try this <connolistbox.selectedindices.clear()>
rmshah
Developer
|
|
|
|
|
Is there a way to determine how many rows exist in the statusstrip control when the layout style = flow?
Example: you have a status strip control at the bottom of the form which contains 10 or so status labels. When the form is maximized, the labels look fine. When the form is resized, the status strip adds a second row to push some of the labels down that no longer fit on the first row.
|
|
|
|
|
Hi,
If everything else fails, you could divide the status strip height by the smallest value
it ever had.
|
|
|
|
|
"That'll do pig, that'll do." (from Babe the movie).
Thanks for the idea!
|
|
|
|