|
redjoy wrote: The code does not need to work with data from other files. All the data needed is already contained within each workbook.
...
The format of each Workbook is the same. The code for each workbook is identical.
You're missing the point. The code (all 15 copies of it) DOES work with the data from every workbook. You're trying to avoid maintaining 15 copies of the code, so you need to have only a single copy of it somewhere. That single copy needs to get at the data for all 15 workbooks.
But, as you post some of the code, you have a problem. You're handling the events fired by changes in the worksheet. This makes it very difficult to seperate the code from the data, and hence keep only a single copy of the code outside of the workbooks.
redjoy wrote: I was not able to find out any thing about add-ins using the VBA behind a worksheet.
That's because you can't. An Add-In is written in C++, C#, VB.NET, or something else that generates "real code" and is completely seperate from any workbooks.
I'd say your best bet is to write this as an Add-In to Excel.
|
|
|
|
|
I have my VBA script code in one XL file and then refer this file, from the file with the data.
If you clear the data sheets leaving only one (empty sheet) and saves this file as say MyCode.xls
Then open the VBA editor for this file, and goto project Explorer. rightclick on the the spreadsheet file, and choose properties.
That should enable you to give you code a specific name, its practical if it could start with 'a'.
If you then also open the spreadsheet containing only the data, again open the VBA editor, and in the project explorer select the data spreadsheet. Then goto "tools" and "references". This opens the ref's dialog. Here you should be able to locate your code among the many lines. (If the name of your code starts with 'a' it should sort to the top Check the box.
That should make your code freely available from the datasheet.
I use this approach from excel 2003, and the only downside I have found is that the references have absolute paths.
Regrads *Henrik
|
|
|
|
|
Hi every one..
I have a VB 2005 application and I am doing error handling by “on error goto”.
I wanted to create a log file if there is any error..
I have done some work in C and linux and wondering if there is any way that I can just echo a string to a text log file the way we are able to do in c by just using ‘>’ or some thing similar so that I do not have to open and close the target file each time…
Regards
Nishkarsh
|
|
|
|
|
you should look at try/catch vs on error goto
Private Sub LogMessageToLocalFile(ByVal sMessage As String)
Try
Dim oFile As New System.IO.StreamWriter("c:\myapperrors.log", True)
oFile.WriteLine(sMessage)
oFile.Flush()
oFile.Close()
oFile = Nothing
Catch
End Try
End Sub
|
|
|
|
|
Don't use on error goto. Use structured exception handling.
And have a google for "log4net" - its a free library for logging, and its excellent.
|
|
|
|
|
I've created a basic User Control with VB.NET that works fine in both a Windows Form and a WEB Page.
I'm using the following code to load the User Control into the WEB Page.
<object id="MyUserControl" classid="http:MyUserControl.dll#MyUserControl.TimerControl"></object>
After I sign the User Control it stops working in the WEB Page but is fine in the Windows Form.
What must I now do to enable the Signed User Control to work in the WEB page?
Regards
Andy Dale
|
|
|
|
|
I have a form which has a button called "Modify Intrest" and when you click it, it brings up a password box and asks for the password. What I wanted was if password was typed in wrong three times, a message to display and then when you click OK, the application to close.
If you type the password in correctly, I want an intrest rate box to display and you have to type in a number and it is written to a file ir.txt
Here is code I have:
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click<br />
<br />
If txtIntrest.Text = ("") Then<br />
MsgBox("Please Enter Intrest Rate", MsgBoxStyle.Exclamation)<br />
Exit Sub<br />
End If<br />
<br />
<br />
If Not txtIntrest.Text.Equals(myline) Then<br />
<br />
<br />
<br />
Static passnum As Integer<br />
Do<br />
Dim pass As String = InputBox("Enter the Password", "Enter Password", "", )<br />
<br />
<br />
If pass = "Password" Then<br />
<br />
Dim intrest As String = InputBox("Enter The New Intrest", "Enter Intrest Rate", "", )<br />
<br />
txtIntrest.Text = (intrest)<br />
<br />
Dim theFile As FileStream = File.Create("ir.txt")<br />
Dim writer As StreamWriter = New StreamWriter(theFile)<br />
writer.WriteLine(txtIntrest.Text)<br />
writer.Close()<br />
theFile.Close()<br />
Exit Sub<br />
Exit Do<br />
Else<br />
Loop Until passnum = 3<br />
passnum = +1<br />
End If<br />
<br />
MsgBox("You have had three attempts to input password, Program will now close for security reasons", MsgBoxStyle.Critical)<br />
Application.Exit()<br />
<br />
<br />
<br />
<br />
<br />
<br />
End If<br />
<br />
End Sub
I messed it up slightly and not sure how to fix it, any ideas?
In the end we're all just the same
|
|
|
|
|
Dave McCool wrote: Loop Until passnum = 3
passnum = +1
End If
You need to show the password dialog again inside this loop and check if it is entered right. This code doesn't allow anyone to try again.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks, but I am not 100% sure how to do this. I took out the code so it looks like this:
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click<br />
<br />
If txtIntrest.Text = ("") Then<br />
MsgBox("Please Enter Intrest Rate", MsgBoxStyle.Exclamation)<br />
Exit Sub<br />
End If<br />
<br />
<br />
If Not txtIntrest.Text.Equals(myline) Then<br />
<br />
Dim pass As String = InputBox("Enter the Password", "Enter Password", "", )<br />
<br />
<br />
If pass = "Password" Then<br />
<br />
Dim intrest As String = InputBox("Enter The New Intrest", "Enter Intrest Rate", "", )<br />
<br />
txtIntrest.Text = (intrest)<br />
<br />
Dim theFile As FileStream = File.Create("ir.txt")<br />
Dim writer As StreamWriter = New StreamWriter(theFile)<br />
writer.WriteLine(txtIntrest.Text)<br />
writer.Close()<br />
theFile.Close()<br />
Exit Sub<br />
<br />
End If<br />
<br />
End If<br />
<br />
End Sub
So the password box just closes when the wrong password is input. I want the password box to keep displaying istead of closing and if you type password wrong three times, this code to execute:
MsgBox("You have had three attempts to input password, Program will now close for security reasons", MsgBoxStyle.Critical)<br />
Application.Exit()
but I was told I could do this with a loop, but was not sure how I had code:
Static passnum As Integer<br />
Do<br />
<br />
passnum = +1<br />
Loop Until passnum = 3
but was not sure where to put it so it worked, any ideas?
In the end we're all just the same
|
|
|
|
|
What code can I use to end a VB 6.0 program from the same program or another program?
|
|
|
|
|
From the same program, see http://www.mvps.org/vbvision/visual_basic_tips.htm[^]
From another program you have to send a WM_CLOSE message to the application main window.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
I am exporting a dataset to Excel.
I can successfully view the dataset in Excel however, there are
special characters that are appearing in the form of Â, â€" and
others.
My code in VB starts off like this:
Response.Clear()
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("content-disposition",
"attachment;filename=GeneralInquiry.xls")
I've tried setting the Response.Charset = "" but that doesn't do
anything either.
Would anyone know what could be causing this and/or how to fix it?
Thank you.
|
|
|
|
|
Is it in ASP.NET ?
Try using HtmlEncode and HtmlDecode ? This solved my problem for hyphen character.
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
Please read the forum guidelines. Do not use urgent in your message titles.
|
|
|
|
|
Please don't use words like urgent. It is consider very rude around here.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi forum,
i like to implement my own DataTypes.
Sample:
DIM X as PARTNUMBER
DIM Y as LIST (OF PARTNUMBER) .....
where PARTNUMBER is my own Datatype with special checks, like PARTNUMBER must have 8 digits, first DIGIT must be character etc.
I like to use this own datatypes in the same way as the base types STRING, INTEGER, .....
Questions:
1) Implementation as CLASS or STRUCTURE ?
2) Which interfaces are necessary ?
3) Any samples available ?
regards,
bauer
|
|
|
|
|
Problem solved, using TypeConverter is the solution.
|
|
|
|
|
How to read an XML file, Which is stored as a resource file in a dll using VB 6.0.
DS
|
|
|
|
|
There should be plenty on a google search for this topic.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Dear Sir/Mam,
I have 1 question regarding xml file verification in vb
I have 1 application to create a .xml file in vb but after creating
this file I want to check whether is it in correct format or not?
& show to user whether error occured in that file.
In that I have not a xml schema.
How can I do it?
In advance Thanx
Have a nice time
|
|
|
|
|
kripa ostwal wrote: I want to check whether is it in correct format or not?
& show to user whether error occured in that file.
In that I have not a xml schema.
What do you mean by 'correct'? That the file is well-formed, or that the data structure adheres to your expectations?
Attempting to parse the XML file will determine whether it is well-formed. Checking that the data structure adheres to your expectations will be difficult if you don't have a schema to validate the document against.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Sir I just want to check that
Is it in well formed or not? &
If is not in well formed just display where is error?
Hope I will get answer.
Thanking in advance
|
|
|
|
|
Hello,
I got to link my VB.net application to Microsoft Outlook 2000. I have to file/save email messages from inbox to public folders and extract message and attachments to update in database. I am new to Outlook programming, can anyone guide for following issues:
- Can I write Office COM Addin in VB 2005 for Outlook 2000 or I have to use VB6 or macros.
- What information I need to save in database in order to track email message back in exchange server's public folders.
I will appreciate for your help.
Nas
|
|
|
|
|
hi
i work on a project that need to rasterize svg files...
i search the web but can't find any source code or activex for doing this.
anyone can help me ?
also is there a way that show SVG file in browser without plugin installed ?
thanx
|
|
|
|
|
mehdi0016 wrote: also is there a way that show SVG file in browser without plugin installed ?
Obviously not, unless it's a browser that has the plugin by default.
I think the best way would be to capture the screen of a browser that's rendering the SVG.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|