# HwpCtrl의 GetTableCellAddr을 대체할 기능

**URL:** <https://forum.developer.hancom.com/t/hwpctrl-gettablecelladdr/934>\
**Category:** 한글 오토메이션\
**Created:** [9월 20, 2023, 8:19오전 UTC](https://forum.developer.hancom.com/t/hwpctrl-gettablecelladdr/934 "2023-09-20T08:19:52Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![user16](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.developer.hancom.com/user16/32/785_2.png) [@user16](https://forum.developer.hancom.com/u/user16)\
**Post date:** [9월 20, 2023, 2:10오후 UTC](https://forum.developer.hancom.com/t/hwpctrl-gettablecelladdr/934/2 "2023-09-20T14:10:11Z")

</div>

안녕하세요?  
어떤 언어를 사용하시는지 모르겠지만,  
파이썬 기준으로 제가 만들어 쓰는 함수는 아래와 같습니다.

```auto
def GetTableCellAddr():
    if not hwp.CellShape: # 표 안에 있을 때만 CellShape 오브젝트를 리턴함
        raise AttributeError("현재 캐럿이 표 안에 있지 않습니다.")
    return hwp.KeyIndicator()[-1][1:].split(")")[0]

def SetTableCellAddr(addr):
    init_addr = hwp.KeyIndicator()[-1][1:].split(")")[0]
    if not hwp.CellShape: # 표 안에 있을 때만 CellShape 오브젝트를 리턴함
        raise AttributeError("현재 캐럿이 표 안에 있지 않습니다.")
    if addr == hwp.KeyIndicator()[-1][1:].split(")")[0]:
        return
    hwp.Run("CloseEx")
    hwp.FindCtrl()
    hwp.Run("ShapeObjTableSelCell")
    while True:
        current_addr = hwp.KeyIndicator()[-1][1:].split(")")[0]
        hwp.Run("TableRightCell")
        if current_addr == hwp.KeyIndicator()[-1][1:].split(")")[0]:
            SetTableCellAddr(init_addr)
            hwp.Run("Cancel")
            raise AttributeError("입력한 셀주소가 현재 표의 범위를 벗어납니다.")
        if addr == hwp.KeyIndicator()[-1][1:].split(")")[0]:
            return
    
    return hwp.KeyIndicator()[-1][1:].split(")")[0]

```

도움이 되었길 바랍니다^^

---

_[View the full topic](https://forum.developer.hancom.com/t/hwpctrl-gettablecelladdr/934)._
