![]() |
How to determine the current position of an open .xls file?
Hello, friends,
We automate Excel from C#.net. Once a .xls file is openned, users may work on any part of it. When this .xls file is closed, our app needs to remember the current position, such as current workSheet, current row number, current column number, etc. When our app opens this .xls file next time, it will go to that position directly so that users may continue. But, how to determine current row number, and etc. I looked up those properties/methods, none of them look like for this job: I could not find ActiveCell property in worksheet, for instance. Any reference paper or sample source code? Thanks a lot. |
How to determine the current position of an open .xls file?
When the workbook is saved, Excel "remembers" the activesheet and activecell.
So, you can use the ActiveSheet and ActiveCell objects. As a test, put this in the workbook code module: Private Sub Workbook_Open() MsgBox "Current location: " & ActiveSheet.Name & "!" & ActiveCell.Address End Sub -- Hope that helps. Vergel Adriano "Andrew" wrote: Hello, friends, We automate Excel from C#.net. Once a .xls file is openned, users may work on any part of it. When this .xls file is closed, our app needs to remember the current position, such as current workSheet, current row number, current column number, etc. When our app opens this .xls file next time, it will go to that position directly so that users may continue. But, how to determine current row number, and etc. I looked up those properties/methods, none of them look like for this job: I could not find ActiveCell property in worksheet, for instance. Any reference paper or sample source code? Thanks a lot. |
How to determine the current position of an open .xls file?
Those .xls files are read only. When users work on a .xls file, he/she may
click Bookmark button in our app to bookmark wherever he/she is currently working on. Our app then will get the current position and save them into database. Next time users open the same .xls again (read only), our app will list all bookmarks to allow users to "jump onto" that position by doubl-clicking one of them. Any ideas? Thanks a lot. "Vergel Adriano" wrote: When the workbook is saved, Excel "remembers" the activesheet and activecell. So, you can use the ActiveSheet and ActiveCell objects. As a test, put this in the workbook code module: Private Sub Workbook_Open() MsgBox "Current location: " & ActiveSheet.Name & "!" & ActiveCell.Address End Sub -- Hope that helps. Vergel Adriano "Andrew" wrote: Hello, friends, We automate Excel from C#.net. Once a .xls file is openned, users may work on any part of it. When this .xls file is closed, our app needs to remember the current position, such as current workSheet, current row number, current column number, etc. When our app opens this .xls file next time, it will go to that position directly so that users may continue. But, how to determine current row number, and etc. I looked up those properties/methods, none of them look like for this job: I could not find ActiveCell property in worksheet, for instance. Any reference paper or sample source code? Thanks a lot. |
How to determine the current position of an open .xls file?
In that case, it looks like persisting the bookmarks in a text file like an
INI file or the Registry might be your options. Check out the link below which shows how to work with INI files. http://www.exceltip.com/st/Private_P...Excel/490.html -- Hope that helps. Vergel Adriano "Andrew" wrote: Those .xls files are read only. When users work on a .xls file, he/she may click Bookmark button in our app to bookmark wherever he/she is currently working on. Our app then will get the current position and save them into database. Next time users open the same .xls again (read only), our app will list all bookmarks to allow users to "jump onto" that position by doubl-clicking one of them. Any ideas? Thanks a lot. "Vergel Adriano" wrote: When the workbook is saved, Excel "remembers" the activesheet and activecell. So, you can use the ActiveSheet and ActiveCell objects. As a test, put this in the workbook code module: Private Sub Workbook_Open() MsgBox "Current location: " & ActiveSheet.Name & "!" & ActiveCell.Address End Sub -- Hope that helps. Vergel Adriano "Andrew" wrote: Hello, friends, We automate Excel from C#.net. Once a .xls file is openned, users may work on any part of it. When this .xls file is closed, our app needs to remember the current position, such as current workSheet, current row number, current column number, etc. When our app opens this .xls file next time, it will go to that position directly so that users may continue. But, how to determine current row number, and etc. I looked up those properties/methods, none of them look like for this job: I could not find ActiveCell property in worksheet, for instance. Any reference paper or sample source code? Thanks a lot. |
All times are GMT +1. The time now is 11:07 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com