Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Can you use application.user to define the path fully?
Or use a filescriptingobject - find folder to find the test folder then the right place -----Original Message----- 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 ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ . |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() this should point you in the right direction: Dim sP As String,sD as string sp = Environ("USERPROFILE") sd = lcase(sp & "\Desktop\") if lcase(MyBook.fullname) like sd & "*" & ".htm*" then msgbox "gotcha" endif keepITcool < email : keepitcool chello nl (with @ and .) < homepage: http://members.chello.nl/keepitcool nikolaosk wrote: 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 mi question. thanks a lot |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Contatenate folder path strings, how ? | Excel Worksheet Functions | |||
Relative Path to a Folder | Excel Discussion (Misc queries) | |||
Setting a path to a folder | Excel Discussion (Misc queries) | |||
Browse button on form for folder path | Excel Discussion (Misc queries) | |||
how to change path name of html source folder ? | Excel Worksheet Functions |