🤍 전 강의 25% 할인 중 🤍

2024년 상반기를 돌아보고 하반기에도 함께 성장해요!
인프런이 준비한 25% 할인 받으러 가기 >>

  • 카테고리

    질문 & 답변
  • 세부 분야

    업무 자동화

  • 해결 여부

    해결됨

1강 질문입니다..

23.03.10 17:46 작성 조회수 1.11k

1

시작하자마자 턱에 걸리네요ㅠㅠ

파이썬에서 아래와 같이 입력했는데

import win32com.client as win32
hwp = win32.gencache.EnsureDispatch(hwpframe.hwpobject)

이런 결과가 나오네요... 어떻게 해야할지 모르겠습니다. 도와주세요.

C:\Users\hwa0h\anaconda3\python.exe C:\PPP1\test.py 
Traceback (most recent call last):
  File "C:\PPP1\test.py", line 2, in <module>
    hwp = win32.gencache.EnsureDispatch(hwpframe.hwpobject)
NameError: name 'hwpframe' is not defined

Process finished with exit code 1

답변 1

답변을 작성해보세요.

2

hwpframe.hwpobject 는 따옴표로 둘러싸여 있어야 합니다^^ 수정 후 다시 실행해 보시기 바랍니다ㅎㅎ

 

 

JJJ님의 프로필

JJJ

질문자

2023.03.10

감사합니다... 너무 간단한 실수였네요..
말씀하신대로 따옴표를 붙였습니다.

import win32com.client as win32
hwp = win32.gencache.EnsureDispatch("hwpframe.hwpobject")

근데 이런 오류가 뜨네요..ㅠ

C:\Users\hwa0h\anaconda3\python.exe C:\PPP1\test.py 
Traceback (most recent call last):
  File "C:\Users\hwa0h\anaconda3\lib\site-packages\win32com\client\dynamic.py", line 86, in _GetGoodDispatch
    IDispatch = pythoncom.connect(IDispatch)
pywintypes.com_error: (-2147221005, '잘못된 클래스 문자열입니다.', None, None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\PPP1\test.py", line 2, in <module>
    hwp = win32.gencache.EnsureDispatch("hwpframe.hwpobject")
  File "C:\Users\hwa0h\anaconda3\lib\site-packages\win32com\client\gencache.py", line 618, in EnsureDispatch
    disp = win32com.client.Dispatch(prog_id)
  File "C:\Users\hwa0h\anaconda3\lib\site-packages\win32com\client\__init__.py", line 117, in Dispatch
    dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch, userName, clsctx)
  File "C:\Users\hwa0h\anaconda3\lib\site-packages\win32com\client\dynamic.py", line 106, in _GetGoodDispatchAndUserName
    return (_GetGoodDispatch(IDispatch, clsctx), userName)
  File "C:\Users\hwa0h\anaconda3\lib\site-packages\win32com\client\dynamic.py", line 88, in _GetGoodDispatch
    IDispatch = pythoncom.CoCreateInstance(
pywintypes.com_error: (-2147221005, '잘못된 클래스 문자열입니다.', None, None)

Process finished with exit code 1 
  1. 혹시 PC에 설치된 아래아한글 버전이 어떻게 되나요?ㅎ

 

  1. hwp = win32.Dispatch("hwpframe.hwpobject")

로 실행해보고 결과를 알려주시겠어요?ㅎ

JJJ님의 프로필

JJJ

질문자

2023.03.10

이런결과가 뜹니다. 한글은 2018버전 쓰고 있습니다.

import win32com.client as win32 
hwp = win32.Dispatch("hwpframe.hwpobject")
C:\Users\hwa0h\anaconda3\python.exe C:\PPP1\test.py 
Traceback (most recent call last):
  File "C:\Users\hwa0h\anaconda3\lib\site-packages\win32com\client\dynamic.py", line 86, in _GetGoodDispatch
    IDispatch = pythoncom.connect(IDispatch)
pywintypes.com_error: (-2147221005, '잘못된 클래스 문자열입니다.', None, None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\PPP1\test.py", line 2, in <module>
    hwp = win32.Dispatch("hwpframe.hwpobject")
  File "C:\Users\hwa0h\anaconda3\lib\site-packages\win32com\client\__init__.py", line 117, in Dispatch
    dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch, userName, clsctx)
  File "C:\Users\hwa0h\anaconda3\lib\site-packages\win32com\client\dynamic.py", line 106, in _GetGoodDispatchAndUserName
    return (_GetGoodDispatch(IDispatch, clsctx), userName)
  File "C:\Users\hwa0h\anaconda3\lib\site-packages\win32com\client\dynamic.py", line 88, in _GetGoodDispatch
    IDispatch = pythoncom.CoCreateInstance(
pywintypes.com_error: (-2147221005, '잘못된 클래스 문자열입니다.', None, None)

Process finished with exit code 1

(너무 무책임한 말씀 드리는 것 같아 죄송하지만ㅜ)
한/글 2018을 삭제 후 재설치해보시기를 바랍니다.
혹시 다른 한/글 버전이 같이 설치되어 있다면
그것도 모두 삭제해주시면 좋겠습니다.

 

JJJ님의 프로필

JJJ

질문자

2023.03.11

네 해보겠습니다~~^^ 감사합니다.

채널톡 아이콘