Author Topic: Is it possible to import type library without file reference  (Read 1553 times)

0 Members and 1 Guest are viewing this topic.

JohnSnow

  • Newt
  • Posts: 52
Is it possible to import type library without file reference
« on: August 26, 2017, 11:22:53 PM »
Hi guys,
When we want to import type library of an application say MS Word, normally we can do it like this:
(vlax-import-type-library :tlb-filename " C:/Program Files/Microsoft Office/Office14/msword.olb"...)

However, I am wondering if we can import the olb without the file reference, the reason being that I cannot assume everyone has the type library in the same directory.

Cheers



VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Is it possible to import type library without file reference
« Reply #1 on: August 27, 2017, 06:03:27 AM »
if it resides in the same directory as winword.exe then try to find the path to Word.Application
Code: [Select]
(setq IName "Word.Application")
(setq ICLSID (vl-registry-read (strcat "HKEY_CLASSES_ROOT\\" IName "\\CLSID")))
(setq IServer (vl-registry-read (strcat "HKEY_CLASSES_ROOT\\CLSID\\" ICLSID "\\LocalServer32")))

JohnSnow

  • Newt
  • Posts: 52
Re: Is it possible to import type library without file reference
« Reply #2 on: August 27, 2017, 07:23:21 AM »
if it resides in the same directory as winword.exe then try to find the path to Word.Application
Code: [Select]
(setq IName "Word.Application")
(setq ICLSID (vl-registry-read (strcat "HKEY_CLASSES_ROOT\\" IName "\\CLSID")))
(setq IServer (vl-registry-read (strcat "HKEY_CLASSES_ROOT\\CLSID\\" ICLSID "\\LocalServer32")))

Thanks a lot.

fools

  • Newt
  • Posts: 72
  • China
Re: Is it possible to import type library without file reference
« Reply #3 on: August 27, 2017, 08:38:44 AM »
Hi, John. Welcome to theswamp! Another way to get path.

Code - Auto/Visual Lisp: [Select]
  1. (setq msw (vlax-get-or-create-object "Word.Application"))

BTW, I like Game of Thrones, too. :laugh:
Good good study , day day up . Sorry about my Chinglish .