| View previous topic :: View next topic |
| Author |
Message |
nvgishere General User

Joined: 10 Feb 2010 Posts: 38
|
Posted: Sat Feb 27, 2010 8:17 pm Post subject: Help needed |
|
|
Hi,
I am not familiar with macro development.
I want to do the following using a macro.
I want to check all the rows in column A of a CALC file, for a string ".exe".
If i find a cell, having this value, i want to output a message stating the row number
else, i want to output " no.exe file found".
Please help.. urgent ..
Thanks |
|
| Back to top |
|
 |
turtle47 Power User

Joined: 24 Aug 2008 Posts: 66 Location: Germany
|
Posted: Sat Feb 27, 2010 11:28 pm Post subject: |
|
|
Hello nvgishere
try:
| Code: | Sub Search_Dotexe
Dim oSheet as Object
Dim End_Row as Integer
Dim CellString as String
Dim i as Integer
oSheet = ThisComponent.CurrentController.getActiveSheet()
oCellCursor = oSheet.createCursor()
oCellCursor.GotoEndOfUsedArea(True)
End_Row = oCellCursor.getRangeAddress.EndRow
for i = 0 to End_Row
CellString = oSheet.getCellByPosition(0,i).string
if InStr(CellString,".exe") then
Msgbox ".exe file found in row: " & i + 1 , 64 , "Search Dotexe"
REM: Set the cursor to found cell
'myView = ThisComponent.CurrentController
'myView.Select(mycell)
exit Sub
End if
if i = End_Row then
MsgBox "no.exe file found" , 64 , "Search Dotexe"
end if
next i
End Sub |
Good luck.
JD _________________ My Extensions
Color2Rows and LastSession |
|
| Back to top |
|
 |
nvgishere General User

Joined: 10 Feb 2010 Posts: 38
|
Posted: Wed Mar 03, 2010 12:23 am Post subject: |
|
|
Thanks a lot for the info.
regards
naveen |
|
| Back to top |
|
 |
nvgishere General User

Joined: 10 Feb 2010 Posts: 38
|
Posted: Wed Mar 03, 2010 4:44 am Post subject: |
|
|
Hi JD,
In the above problem,
If there is no .exe filename in any row of column A in the CALC file initially,
we get the message,
"no.exe file found"
I would like to return to the CALC file when (i=END_ROW) condition is encountered, and enter a valid .exe file name in the column A in the CALC file.
Now when i again run the macro , i should be able to get the message
"exe file found in row:"
Is there a provision to achieve the same( ie i should be able to go back to the CALC file from the MACRO and correct it) |
|
| Back to top |
|
 |
|