Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Registering an OCX with VBA

Hello. Is there a way to register an OCX control such as
mscomctl.ocx via VBA? As you know, the manual way is to
go to 'Run' and type in regsvr32 <path & filename of
ocx. In other words, how can I implement the same via
Visual Basic Code? I am trying to automate a process of
registering an OCX so that I do not receive the 'Could
not load an object because it was not found on this
machine' error. My other question is even though I am
using the Packaging Wizard to package my application, I
still receive the error when the program is run on a
different os such as Windows NT. Can the Packaging wizard
not register the ocx appropriately depending on the OS in
which the application is installed? Is there an easy way
to register an OCX regardless of the os that the end-user
will have on his PC? Many thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 214
Default Registering an OCX with VBA

Hi Viswanath Tumu;
Private Declare Function GetSystemDirectory& Lib "kernel32" Alias _
"GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long)

Sub OcxReg(OcxName As String)
Dim sPath As String, tPath As String
sPath = ThisWorkbook.Path & "\" & OcxName
If Dir(sPath) = "" Then MsgBox "File " & sPath & " no found !", 48: Exit
Sub
tPath = Space(255)
tPath = Left(tPath, GetSystemDirectory(tPath, 255)) & "\"
If Dir(tPath & OcxName) = "" Then
FileCopy sPath, tPath & OcxName
Shell tPath & "regsvr32.exe " & OcxName & " /s"
End If
End Sub

MP

"Viswanath Tumu" a écrit dans le
message de ...
Hello. Is there a way to register an OCX control such as
mscomctl.ocx via VBA? As you know, the manual way is to
go to 'Run' and type in regsvr32 <path & filename of
ocx. In other words, how can I implement the same via
Visual Basic Code? I am trying to automate a process of
registering an OCX so that I do not receive the 'Could
not load an object because it was not found on this
machine' error. My other question is even though I am
using the Packaging Wizard to package my application, I
still receive the error when the program is run on a
different os such as Windows NT. Can the Packaging wizard
not register the ocx appropriately depending on the OS in
which the application is installed? Is there an easy way
to register an OCX regardless of the os that the end-user
will have on his PC? Many thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Registering an OCX with VBA

dear Michel,

Many, many thanks for the very helpful comments. I shall
incorporate the same into my code and give it a go.
-----Original Message-----
Hi Viswanath Tumu;
Private Declare Function GetSystemDirectory&

Lib "kernel32" Alias _
"GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal

nSize As Long)

Sub OcxReg(OcxName As String)
Dim sPath As String, tPath As String
sPath = ThisWorkbook.Path & "\" & OcxName
If Dir(sPath) = "" Then MsgBox "File " & sPath & " no

found !", 48: Exit
Sub
tPath = Space(255)
tPath = Left(tPath, GetSystemDirectory(tPath, 255))

& "\"
If Dir(tPath & OcxName) = "" Then
FileCopy sPath, tPath & OcxName
Shell tPath & "regsvr32.exe " & OcxName & " /s"
End If
End Sub

MP

"Viswanath Tumu" a

écrit dans le
message de ...
Hello. Is there a way to register an OCX control such

as
mscomctl.ocx via VBA? As you know, the manual way is to
go to 'Run' and type in regsvr32 <path & filename of
ocx. In other words, how can I implement the same via
Visual Basic Code? I am trying to automate a process of
registering an OCX so that I do not receive the 'Could
not load an object because it was not found on this
machine' error. My other question is even though I am
using the Packaging Wizard to package my application, I
still receive the error when the program is run on a
different os such as Windows NT. Can the Packaging

wizard
not register the ocx appropriately depending on the OS

in
which the application is installed? Is there an easy

way
to register an OCX regardless of the os that the end-

user
will have on his PC? Many thanks.



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
FM20.dll needs re-registering all the time Jacko[_2_] Excel Discussion (Misc queries) 1 May 15th 08 02:22 AM
i dont know what file to name when registering Calender Control Kess Excel Discussion (Misc queries) 1 December 17th 07 09:24 AM
ActiveX registering problem with VBA Igor Tandetnik Excel Programming 0 February 11th 04 03:32 PM
ActiveX registering problem with VBA Keith Willshaw Excel Programming 0 February 11th 04 03:07 PM
error in registering msadox.dll Sameer S. Ali Excel Programming 0 September 27th 03 12:09 AM


All times are GMT +1. The time now is 05:16 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"