找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1480|回复: 0

ActiveX/VBA 技术通讯- 1月 2000年

[复制链接]

已领礼包: 145个

财富等级: 日进斗金

发表于 2002-1-7 01:45:42 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
ActiveX/VBA Technical Newsletter - February 2000  
This document is part of    AutoCAD VB(A) Newsletter Archive     



/Note: Have you missed a Newsletter issue? Visit our Newsletter archive at
the following URL:/

http://adn.autodesk.com/techsupp/docs/newsletters.htm
  

Dear AutoCAD ActiveX/VBA Developer,

Table of Content
================

1- How to invoke AutoCAD 2000 based products like MDT, MAP, ... FROM VB?
2- DAO 3.51 not working in VBA on MDT4.0
3- New and Updated solutions
4- New ADN 2000 website, bookmarked URL problems
  

1- How to invoke AutoCAD 2000 based products like MDT, MAP, ETC..., FROM VB?
----------------------------------------------------------------------------

MDT/ADT/MAP are all basically ARX applications which run inside AutoCAD 2000.
When we launch the AutoCAD based application, it searches for the 'acad.rx'
file in the application directory and loads the arx files that are listed in
this file. Normally in VB, we use CreateObject("AutoCAD.Application.15") to
invoke AutoCAD using VB. If there are many AutoCAD 2000 based applications
installed on the computer you are working on, then the CreateObject function
will invoke the AutoCAD application which was used in the last session.

The VB sample shown below uses the SHELL function to invoke MDT4.0. Basically
it gets the file location of 'acad.exe' which is installed under MDT4.0
installation directory from the registry. The path and other information of
AutoCAD application associated with  MDT 4.0 is available in the registry at
the following location

HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\R15.0\ACAD-3:409

Here is some sample VB code which invokes MDT 4.0

'Insert the following code in a Module
Public Const HKEY_CLASSES_ROOT = &H80000000
Public Const HKEY_CURRENT_USER = &H80000001
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const HKEY_USERS = &H80000003
Public Const KEY_ALL_ACCESS = &H3F

Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias _
   "RegOpenKeyExA" (ByVal hKey As Long, _
   ByVal lpSubKey As String, ByVal ulOptions As Long, _
   ByVal samDesired As Long, phkResult As Long) As Long

Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" _
  (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, _
  ByRef lpType As Long, ByVal szData As String, ByRef lpcbData As Long) As Long

Public Function ConvertString(tmpVal As String, KeyValSize As Long) As String
   If (Asc(Mid(tmpVal, KeyValSize, 1)) = 0) Then     ' Win95 Adds Null Terminated String...
    ConvertString = Left(tmpVal, KeyValSize - 1)     ' Null Found, Extract From String
   Else                         ' WinNT Does NOT Null Terminate String...
    ConvertString = Left(tmpVal, KeyValSize)         ' Null Not Found, Extract String Only
   End If
End Function

'Insert the following, probably in a commandbutton click event.
Private Sub Command1_Click()
    Dim obj As Object
    Dim apppath As String
    Dim szBuffer As String, dataBuff As String, ldataBuffSize As Long, _
    hKey As Long, phkResult As Long, RetVal As Long, _
    Value As String, RegEnumIndex As Long
    'Create Buffer
    dataBuff = Space(255)
    ldataBuffSize = Len(dataBuff)

    szBuffer = "SOFTWARE\Autodesk\AutoCAD\R15.0\ACAD-3:409\"
    hKey = HKEY_LOCAL_MACHINE
    RegOpenKeyEx hKey, szBuffer, 0, KEY_ALL_ACCESS, phkResult

    Value = "ACADLOCATION"

    RetVal = RegQueryValueEx(phkResult, Value, 0, 0, dataBuff, ldataBuffSize)
    If RetVal = 0 Then
    apppath = ConvertString(dataBuff, ldataBuffSize)
    Shell (apppath & "\acad.exe")
    On Error Resume Next
    Set obj = GetObject(, "AutoCad.Application.15")
    Do
    Err.Clear
    Resume
    Loop While Err.Number = 429
    obj.Visible = True
   Else
    MsgBox "Error in reading the Registry."
   End If
End Sub

The following line in this sample code

szBuffer = "SOFTWARE\Autodesk\AutoCAD\R15.0\ACAD-3:409\" can be changed in
the following way to invoke one of the following application:

Acad 2000   => "SOFTWARE\Autodesk\AutoCAD\R15.0\ACAD-1:409\"
MAP 2000    => "SOFTWARE\Autodesk\AutoCAD\R15.0\ACAD-2:409\"
MDT 4.0     => "SOFTWARE\Autodesk\AutoCAD\R15.0\ACAD-3:409\"
ADT 2.0     => "SOFTWARE\Autodesk\AutoCAD\R15.0\ACAD-4:409\"
LDDT 2.0    => "SOFTWARE\Autodesk\AutoCAD\R15.0\ACAD-5:409\"

NOTE: Please introduce your own error handling functions at appropriate places.
  
  

2- DAO 3.51 not working in VBA on MDT4.0
----------------------------------------

If you want to use DAO 3.51 components in VBA of any application you would
require a design time license. And this design time license is by default
installed by Office 97. MDT 4.0 does install DAO 3.51 components but has a
license only for run time. So ideally all compiled applications using
DAO 3.51 should work under such case. Also installing VB will install
design time license for DAO 3.51 components.

To fix this problem do the following which will add the required registry
key. But before doing this make a back up of the original registry
just in case anything goes wrong.

-----Cut here-----
REGEDIT4
[HKEY_CLASSES_ROOT\Licenses\F4FC596D-DFFE-11CF-9551-00AA00A3DC45]
@="mbmabptebkjcdlgtjmskjwtsdhjbmkmwtrak"
-----Cut here-----

Steps to register:
1. Cut and paste the above code into a text file.
2. Change the file extension to .reg
3. Double-click on the file. (This launches regedit.exe which should
   then report a that it successfully merged the entries into the registry)

Please check in Microsoft's web site for detailed explanation.

Topic: DAO Error After Installing Visual Basic DAO Application

http://support.microsoft.com/support/kb/articles/Q189/6/07.ASP
  

3- New and Updated solutions
----------------------------

FATAL ERROR OR EXCESSIVE MEMORY CONSUMED WHEN RUNNING VBA MACRO
/cgi-bin/solution.pl?SID=45963

HOW TO ENUMERATE PLOTTERS IN AUTOCAD
/cgi-bin/solution.pl?SID=44951

FINDFILE IN VBA
/cgi-bin/solution.pl?SID=44974

HOW TO GET THE GROUP NAME FROM AN ENTITY BELONGING TO A GROUP
/cgi-bin/solution.pl?SID=8779
  

4- New ADN 2000 website, bookmarked URL problems
-------------------------------------------

If you have visited the ADN 2000 website recently you may have noticed that
it has been redesigned. In addition to the reorganization we have shortened
many of the URL's. As a result any of the old URL's you may have bookmarked
will not point to the correct locations anymore. Please update your
bookmarks to point to the appropriate locations.

-----------------------------------------------------------------------------
To subscribe or unsubscribe, go to
http://adn.autodesk.com/techsupp/docs/newsletters.htm
-----------------------------------------------------------------------------

     You received this message as a result of your registration
     on the ADN List Server subscription page.  If you no longer wish
     to receive these messages, read the next section, How to use this
     mailing list.

     How to use this mailing list:

     You may unsubscribe from this e-mail newsletter, or subscribe to
     a variety of other informative e-mail newsletters, by returning
     to the ADN List Server subscription page at
       http://adn.autodesk.com/techsupp/docs/newsletters.htm
     and changing your subscription preferences.

     Alternatively, from the subscribed account you can send an e-mail to
     <Majordomo-partnersys@autodesk.com> with the following command in the
     body of your email message:

     unsubscribe <list-name>

     ----------------------------------------------------------------------

     Autodesk Developer Network (ADN) information and events:

     For information on all ADN topics, please visit:
       http://www.autodesk.com/adn

     ----------------------------------------------------------------------

     THIS DOCUMENT IS PROVIDED FOR INFORMATIONAL PURPOSES ONLY.  The
     information contained in this document represents the current view of
     Autodesk Inc. on the issues discussed as of the date of publication.
     Because Autodesk must respond to change in market conditions, it
     should not be interpreted to be a commitment on the part of Autodesk
     and Autodesk cannot guarantee the accuracy of any information
     presented after the date of publication.
     INFORMATION PROVIDED IN THIS DOCUMENT IS PROVIDED 'AS IS' WITHOUT
     WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT
     LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
     PARTICULAR PURPOSE AND FREEDOM FROM INFRINGEMENT.
     The user assumes the entire risk as to the accuracy and the use of
     this document. This  document may be copied and distributed subject to
     the following conditions:
     1.   All text must be copied without modification and all pages must
          be included
     2.   All copies must contain Autodesk's copyright notice and any other
          notices provided therein
     3.   This document may not be distributed for profit
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-12-5 02:54 , Processed in 0.379533 second(s), 30 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表