|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#16
|
|||
|
|||
|
I'll get you on your way:
Create a file names.txt with records: Name, Email, FileName Name, Email, FileName Create a form with a listbox and a command button in the form's code enter this: private sub Form_Load source = AppPath & "names.txt" Open source For Input As #1 Do While Not EOF(1) Input #1, MyString ListBox1.AddItem = GetSubString(MyString, 1, ",") Loop end sub private sub Command1_Click Dim Email as stirng Dim FileName as string Email = GetEmail(ListBox1.Text) FileName = GetFileName(ListBox1.Text) 'Now you have the email an filenames in a string, now do your 'thing with it end sub Private Function GetEmail(Name as string) source = AppPath & "names.txt" Open source For Input As #1 Do While Not EOF(1) Input #1, MyString if GetSubString(MyString, 1, ",") = Name then GetEmail = GetSubString(MyString, 2, ",") exit function end if Loop end function Private Function GetFileName(Name as string) source = AppPath & "names.txt" Open source For Input As #1 Do While Not EOF(1) Input #1, MyString if GetSubString(MyString, 1, ",") = Name then GetFileName = GetSubString(MyString, 3, ",") exit function end if Loop end function Function GetSubString(str As String, StrNr As Integer, Sep As String) As String Dim Trimmed As String Dim Anser As String Dim PartStr As String Dim StrLen As Integer Dim SepPos As Integer Dim Count As Integer Trimmed = Trim(str) Anser = "" For Count = 1 To StrNr StrLen = Len(Trimmed) If StrLen > 0 Then SepPos = InStr(Trimmed, Sep) If SepPos > 0 Then PartStr = Left(Trimmed, SepPos - 1) Else PartStr = Left(Trimmed, StrLen) SepPos = StrLen End If Trimmed = Trim(Right(Trimmed, StrLen - SepPos)) Anser = Trim(PartStr) Else Anser = "" End If Next Count GetSubString = Anser End Function ------------------------------------------- there may be errors in this since i quickly wrote it here, but you should be able to take care of those. |
|
#17
|
|||
|
|||
|
Thanks to be so patient, I have created the text file and created the form and add your code, I run the macro and then press the button nothing is happening,
the names.txt file is Toyota, totyota@hotmail.com, c:\mydata\Toyota Quarterly Q3-2003-All.xls Toyota, totyota@hotmail.com, c:\mydata\Toyota Quarterly Q3-2003-All.xls Toyota, totyota@hotmail.com, c:\mydata\Toyota Quarterly Q3-2003-Errors.xls Ford, Ford@hotmail.com, c:\mydata\Ford Quarterly Q3-2003-customers.xls Ford, Ford@hotmail.com, c:\mydata\Ford Quarterly Q3-2003-All.xls Ford, Ford@hotmail.com, c:\mydata\Ford Quarterly Q3-2003-Errors.xls |
|
#18
|
||||
|
||||
|
wow... Jo.. you're still pounding away, huh. If you'll send me your code, I'll see if I can work through it.
__________________
Fisherman "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein |
|
#19
|
|||
|
|||
|
I find u writed incorrently:
On Userform1: Private Sub Command1_Click() Dim Email As stirng should be: Private Sub CommandButton1_Click() Dim Email As String And in the GetEmail Function,u should declare MyString variable. It's my found..Hope it's helpful.. |
|
#20
|
|||
|
|||
|
I am still pounding away, and I will not rest until it is completed
without U for me was a dream to be here I have changed line as U recommended to Private Sub CommandButton1_Click() Now when I click the button I get User-defined type not defined I have checked tools>References I am using MS Forms 2.0 Object library Also you have mentioned " in the GetEmail Function,u should declare MyString variable" Could you please show me how to in previous codes Last edited by josephg : October 28th, 2003 at 05:41 PM. |
|
#21
|
|||
|
|||
|
I can run your code that i modified in my pc..And i haven't get the error "User-defined type not defined "..U have vb develope environment or office develope environment??
If u have,U shouldn't get this error.. |
|
#22
|
|||
|
|||
|
I do not know what do you mean by
VB develope environment or office develope environment?? I am using ms office2000 professional edition, Excel2000, then i use tools> macro > to edit or crate macro or forms as I have mentioned before I am using microsoft Form 2.0 object library ?????? |
|
#23
|
|||
|
|||
|
you might want to try and add microsoft office 8.0 and visual basic for appllications + OLE automation to your references.
|
|
#24
|
|||
|
|||
|
ACC2000: VBA Functions Break in Database with Missing References
This article was previously published under Q208218 Moderate: Requires basic macro, coding, and interoperability skills. This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp). For a Microsoft Access 97 version of this article, see 160870. For a Microsoft Access 2002 version of this article, see 283806. SYMPTOMS If you have a procedure that contains a Visual Basic for Applications function, and your database contains a reference to a missing object library or type library, you may receive the following error message when you compile your modules or run the procedure: Compile Error: Can't find project or library CAUSE Your database contains a reference to a database, type library, or object library that is marked as MISSING: <referencename> in the References dialog box. RESOLUTION To remove the missing reference, follow these steps: Open your database. Press ALT+F11 to switch to the Visual Basic Editor. Open a module in Design view. On the Tools menu, click References. Click to clear the check box for the type library or object library marked as MISSING: <referencename>. An alternative to removing the reference is to restore the referenced file to the path specified in the References dialog box. If the referenced file is in a new location, clear the MISSING: <referencename> reference and create a new reference to the file in its new folder. NOTE: In an Access run-time application, you cannot view references from a menu. However, the following article demonstrates how to view references by using code: 209849 ACC2000: How to Loop Through References to View Their Properties MORE INFORMATION Steps to Reproduce Behavior Open the sample database Northwind.mdb. Create a new form. On the Insert menu, click ActiveX Control. In the Select an Activex control list, click Microsoft Forms 2.0 ToggleButton, and then click OK. Save the form as frmReference, and then close it. Close Northwind.mdb and quit Access. Find and rename the Fm20.dll file to Fm20.xxx. Start Access and open Northwind.mdb. Open the module named Startup in Design view. On the Debug menu, click Compile Northwind. Note that you receive the error message described in the "Symptoms" section. Click OK. Note that the References dialog box appears; the following reference is highlighted in the Available References box:MISSING: Microsoft Forms 2.0 Object Library Click Cancel in the Available References dialog box. Find and rename the Fm20.xxx file to Fm20.dll. Repeat step 10 and note that the error message no longer appears. http://support.microsoft.com/defaul...&NoWebContent=1 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > How to send mail from VB to multiple users |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|