OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Help needed

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
nvgishere
General User
General User


Joined: 10 Feb 2010
Posts: 38

PostPosted: Sat Feb 27, 2010 8:17 pm    Post subject: Help needed Reply with quote

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
View user's profile Send private message
turtle47
Power User
Power User


Joined: 24 Aug 2008
Posts: 66
Location: Germany

PostPosted: Sat Feb 27, 2010 11:28 pm    Post subject: Reply with quote

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
View user's profile Send private message
nvgishere
General User
General User


Joined: 10 Feb 2010
Posts: 38

PostPosted: Wed Mar 03, 2010 12:23 am    Post subject: Reply with quote

Thanks a lot for the info.


regards
naveen
Back to top
View user's profile Send private message
nvgishere
General User
General User


Joined: 10 Feb 2010
Posts: 38

PostPosted: Wed Mar 03, 2010 4:44 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group