Name a file from 3 seperate fields 
Author Message
 Name a file from 3 seperate fields

I am trying to name  a file from 3 seperate fields by combining the text and
numbers to create the name.
i.e.
{name}{###.#}{Date} would output name#####.#082902.rtf
can someone help me.


Tue, 15 Feb 2005 02:15:37 GMT  
 Name a file from 3 seperate fields
Hi Josh,

I'm not sure what the problem is. There shouldn't be a problem with
concatenating the results of these fields to create a filename, except that
the result of these fields might have a character that cannot be part of a
filename. Are you having problems with characters that cannot be part of a
filename? If that's the case, then you can create a routine that removes all
of the characters that cannot be part of a filename.

Although this wouldn't suit your purposes, here's an example of removing
anything that is not a letter of the alphabet and saving the file as that
name:

Public Sub Test ()
ActiveDocument.SaveAs FileName:=LettersOnly(sAnyString:=Selection.Text)
End Sub

Public Function LettersOnly(sAnyString As String) As String
For i = Len(sAnyString) To 1 Step -1
    Select Case Asc(Mid(LCase(sAnyString), i, 1))
        ' lowercase a is Asc 97
        ' lowercase z is Asc 123
        Case 97 To 122
            sBuildString = sBuildString & Mid(sAnyString, i, 1)
        Case Else
    End Select
Next i
LettersOnly = Replace(StrReverse(sBuildString), _
    "MaintenanceWindow", "_MW_")
End Function

HTH


Quote:
> I am trying to name  a file from 3 seperate fields by combining the text
and
> numbers to create the name.
> i.e.
> {name}{###.#}{Date} would output name#####.#082902.rtf
> can someone help me.



Tue, 15 Feb 2005 03:15:19 GMT  
 Name a file from 3 seperate fields
Thanks ...but I figured it out...
Newb learning curve and all..I don't know if its the most elegant way but it
works great for what I need. Thanks for the input I can put that to use
also.

Quote:
> Hi Josh,

> I'm not sure what the problem is. There shouldn't be a problem with
> concatenating the results of these fields to create a filename, except
that
> the result of these fields might have a character that cannot be part of a
> filename. Are you having problems with characters that cannot be part of a
> filename? If that's the case, then you can create a routine that removes
all
> of the characters that cannot be part of a filename.

> Although this wouldn't suit your purposes, here's an example of removing
> anything that is not a letter of the alphabet and saving the file as that
> name:

> Public Sub Test ()
> ActiveDocument.SaveAs FileName:=LettersOnly(sAnyString:=Selection.Text)
> End Sub

> Public Function LettersOnly(sAnyString As String) As String
> For i = Len(sAnyString) To 1 Step -1
>     Select Case Asc(Mid(LCase(sAnyString), i, 1))
>         ' lowercase a is Asc 97
>         ' lowercase z is Asc 123
>         Case 97 To 122
>             sBuildString = sBuildString & Mid(sAnyString, i, 1)
>         Case Else
>     End Select
> Next i
> LettersOnly = Replace(StrReverse(sBuildString), _
>     "MaintenanceWindow", "_MW_")
> End Function

> HTH



> > I am trying to name  a file from 3 seperate fields by combining the text
> and
> > numbers to create the name.
> > i.e.
> > {name}{###.#}{Date} would output name#####.#082902.rtf
> > can someone help me.



Tue, 15 Feb 2005 06:56:36 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How to seperate MM/DD/YY into seperate fields in access

2. Seperating First, Middle, Last Name from one field

3. Breaking up a phone number field into seperate fields

4. Referencing two seperate object with the same name

5. Seperating the name in an internet address from the domain

6. Seperating first and last name

7. Splitting strings into seperate fields

8. Seperating Email fields

9. Display Memo field on a seperate form???

10. Seperating multiple e-mail addresses from one form field

11. how to seperate multi field in listbox (like table of access)

12. Combine or seperate the field ???

 

 
Powered by phpBB® Forum Software