Thanks Michael but this is not what I want. This is to set/get the mouse pointer position but I simply want the position of "Rectangular cell highlighter" or whatever you call it in terms of (1,2) ,(5,7) etc to enter the text in different cells.
The attached macro should do what you intend. You need to activate the module and run it.
The macro records the X & Y mouse co-ordinates of the mouse in active view of the active Document. You can set a value and click set to move mouse pointer.
This was made in SW 2012 so if your version is any different then you need to change references.
Hope it helps!!!
This is not what i want. I want to get/set current cell position in microsoft excel so as to enter text at various cells wrt to current cell position.
If I am reading you correctly, you simply want to enter data into cells in the background while Solidworks is running. Given you already know which cells you want to enter data into, this should be fairly simple. Let me know if the following code helps! I assume you have already done so, but please make sure you add the excel 12.0 object type reference to your program!
Dim swApp As Object
Dim xlApp As Excel.Application
Dim xlbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
Set xlApp = CreateObject("excel.application") 'Sets Excel Application Object
Set xlbook = Excel.Workbooks.Add("") 'Creates a New Workbook
'Set xlbook = Excel.Workbooks.Open("C:\temp\testworkbook.xls", , False) 'Sets the Workbook to an Existing One, the True/false sets the Workbook to Read Only
Set xlsheet = xlbook.Worksheets("Sheet2") 'Set Sheet by Tab Name
'Set xlsheet = xlbook.Worksheets(2) 'Set Sheet by Index Number (starting at 1)
With xlsheet 'Edit the Worksheet Tab Selected above
.Cells(1, 1).Value = "Test" 'Edits Column A, Row 1
.Cells(2, 5).Value = "B5" 'Edits Column B, Row 5
xlApp.Visible = True 'Makes the Excel Workbook Visible
'xlbook.PrintOut 'Prints the Workbook
'xlbook.Close (True) 'Closes the Workbook and saves changes
'xlApp.Quit 'Closes the current instance of Excel referenced above, this should NOT close instances of excel you did not open with the code
Set swApp = Application.SldWorks
I believe this might be what you are looking for. You must have the Excel reference in tools selected. The program below should print out the row, column and value or the active worksheet to the immediate window. I normally have just one excel open because if there is more than one instance of Excel open this may grab the wrong Excel.
'Written 04-09-2012 Dan Miel
Dim xlApp As New Excel.Application
Set xlApp = GetObject(, "Excel.Application")
Debug.Print "Y = " & xlApp.ActiveCell.Row
Debug.Print "X = " & xlApp.ActiveCell.Column
Debug.Print "V = " & xlApp.ActiveCell.Value
Sorry For late reply. I found the solution after googling.
Here's what i found.
xlapp.ActiveCell.Row 'to get row no
xlapp.ActiveCell.Column 'to get column no
xlapp.ActiveCell.Offset(1,0).Select 'to move to row below
xlapp.ActiveCell.Offset(0,1).Select 'to move to next column