N
nikolaosk
hello there,
i have to check whether a user has saved a particular workbook with the
..htm or .html extension. that is the easy bit.
the user has to save the workbook in a folder on the desktop.
i take the workbook's fullname (see sub below) and check to see if the
last 4 or 5 characters are .htm or .html respectively
please bear in mind that we are not intrested in the name of the
workbook. we just want him to give a name in the workbook and save it
as .htm or .html. see an example below.
C:\Documents and Settings\nkantzelis\Desktop\test\*****.htm
that is the first bit.
now i want to check that if he saved it in the particular folder named
"test".
that is not a problem you might think. just take the 35 or so
characters from the left of the full name and see if test is included.
there is a problem though.
every user is going to log on on a different machine and have a
different user name
so the path will be like this
C:\Documents and Settings\********\Desktop\test\*****.htm
i can take the string using
workbookname= Application.Workbooks(1).fullname
so now workbookname contains something like this
C:\Documents and Settings\********\Desktop\test\*****.htm
is there any way that i can check that in this string there is a "test"
substring?
how can i do it using the Like operator?
that is mi question.
thanks a lot
-----------------------------------------------------------
Sub checkfilenameextension()
'On Error Resume Next
Set app = Application.Workbooks(1)
FullName = app.FullName
MsgBox FullName
MsgBox Right(FullName, 33)
If Right(FullName, 4) <> ".htm" _
And Right(FullName, 5) <> ".html" Then
ECDLANSWER = 2
MsgBox ("error")
Exit Sub
End If
MsgBox ("ok")
End Sub
i have to check whether a user has saved a particular workbook with the
..htm or .html extension. that is the easy bit.
the user has to save the workbook in a folder on the desktop.
i take the workbook's fullname (see sub below) and check to see if the
last 4 or 5 characters are .htm or .html respectively
please bear in mind that we are not intrested in the name of the
workbook. we just want him to give a name in the workbook and save it
as .htm or .html. see an example below.
C:\Documents and Settings\nkantzelis\Desktop\test\*****.htm
that is the first bit.
now i want to check that if he saved it in the particular folder named
"test".
that is not a problem you might think. just take the 35 or so
characters from the left of the full name and see if test is included.
there is a problem though.
every user is going to log on on a different machine and have a
different user name
so the path will be like this
C:\Documents and Settings\********\Desktop\test\*****.htm
i can take the string using
workbookname= Application.Workbooks(1).fullname
so now workbookname contains something like this
C:\Documents and Settings\********\Desktop\test\*****.htm
is there any way that i can check that in this string there is a "test"
substring?
how can i do it using the Like operator?
that is mi question.
thanks a lot
-----------------------------------------------------------
Sub checkfilenameextension()
'On Error Resume Next
Set app = Application.Workbooks(1)
FullName = app.FullName
MsgBox FullName
MsgBox Right(FullName, 33)
If Right(FullName, 4) <> ".htm" _
And Right(FullName, 5) <> ".html" Then
ECDLANSWER = 2
MsgBox ("error")
Exit Sub
End If
MsgBox ("ok")
End Sub