having an issue with setting up ImageMagick in my VB6 IDE - vb6

I found ImageMagick online and am trying to add it to one of my legacy VB6 projects to convert some .jpgs --> PDFs.
I installed and registered the dll:
ImageMagick-7.0.7-29-Q16-x64-dll.exe
I added the reference in my projects without any issues:
ImageMagicObject 1.0 Type Library
The problem now comes when I try to create an object of ImageMagickObject.MagickImage.1 like so:
'Dim your object as a simple Object
Dim imgMkObj As Object
'Set your object
Set imgMkObj = CreateObject("ImageMagickObject.MagickImage.1")
'Convert your image
MsgBox imgMkObj.Convert("C:\source.jpg", "-resize=800x600", "C:\destination.pdf")
When it gets to the SET part, it gives me an error
Run Time error 429
ActiveX component can't create object
And I really have no idea how to proceed from here. Is there a ImageObject component that I need to have added in my app (OCX) to make this work. I'm trying to programmatically (not command line) to change the formats of some documents.
Can anyone shed some light on this?
Thanks.

It looks like you've installed the 64 bit version of the DLL.
If they offer a 32 bit install that might solve your problem?
VB6 is a 32 bit application

Related

VB6 project issue which applying DAO3.6 library

I have an VB6 application.
When trying to Start it prompts an error ActiveX component can't create object
The program is failed in below line
Set GCIWCon = CreateObject("Dbsecurity.database")
I have checked that DAO3.6 library is existed and below line can be executed
CreateObject ("Excel.Sheet")
Thus, I assumed that DAO3.6 is working properly, but the object "Dbsecurity.database" is not found.
I do have a rough idea about the DAO library but I have no idea what is missing in order to make the issued line work.
Can anyone suggest what the object "Dbsecurity.database" can be and how to include it in the VBA?
Thanks

VB6 DomDocument.SetProperty missing

I am having to make an old VB6 application run on Windows 10. The issue was that the reference to DomDocument40 is not part of Windows 10 (or 7 i believe) and instead uses DomDocument60 (part of the msxml6.dll).
The line was:
Dim oXMLDom1 As New DOMDocument40
To ensure backward compatibility i believe it is better to use DomDocument which will automatically use the appropriate version on the system. Is this correct?
So my line is now:
Dim oXMLDom1 As New DOMDocument
However, now when I try to run the application i get the compiler error 'Method or data member not found.' This relates to the following line (which I now see setProperty is not supported in msxml6):
oXMLDom1.setProperty "SelectionLanguage", "XPath"
Can anyone tell me firstly if using DomDocument instead of DomDocument40 is the recommended solution. And if so what I should do about setProperty no longer being available?
I know the best solution is to write this in almost any other language ;) but that's not an option.
This is probably not an answer, but you should be able to safely comment out that line as XPath is the default value from MSXML 4.0 onwards. If the application is to run on Win10, XPath should be the default.
EDIT
After some testing, I think all you need to do is change this:
Dim oXMLDom1 As New DOMDocument
To this:
Dim oXMLDom1 As New MSXML2.DOMDocument
The only way I got the SetProperty method to fail like that was explicitly adding a reference to Microsoft XML, version 2.0 and declaring the object without MSXML2 (that also fails, as the class name is MSXML for that version). I tested this adding references from Microsoft XML, v2.6 to Microsoft XML, v6.0 and it works without problems for all of them. Please notice that I did all this testing on an XP machine, as I have no way to test it on a Win10 PC right now, but it should work fine.

Adding VBA reference in VB6.0

I have a old VB 6.0 application written by someone else. When i compile the application, it throws error on every line of code where VBA reference is required so fro e.g. it throws an error in the following lines:
Left$, Chr, Trim$
As soon as I prefix it with VBA.Left$, the error goes away. I was looking at the list of project References and saw only one missing reference called "Microsoft DTS run time 1.0". Where can I get this reference from and how can I add this in VB application. Also, is there any way, I can add VBA reference to VB application. I am running this VB application on XP machine.
any help will be appreciated.
Then you should install Microsoft DTS runtime:
How to: Install Support for Data Transformation Services Packages:
https://technet.microsoft.com/en-us/library/ms143755(v=sql.105).aspx
After, add the VBA reference (if is missing)
If you look at your list of Available References, you should see one for Visual Basic For Applications. Make sure this is checked and you will be good to go.
If there is more than one reference for VBA, select the one for msvbvm60.dll.

ActiveX component can't create object vbs code error

This vbs code show error when I click to execute it
Set objIP = CreateObject( "SScripting.IPNetwork" )
strIP = objIP.DNSLookup( "www.google.com" )
WScript.Echo "IP address of www.google.com: " & strIP
Set objIP = Nothing
The error is here in this is pic.
It seems to me that activeX components are often poorly documented and if you can't get stuff working, you need a method that bypasses the documentation and goes directly to what you've actually got available on you machine.
I had documentation that said something like:
Set library = CreateObject("somethinglibLib.SomethingLibrary.2")
would work, it didn't... where now?
I found that the "somethinglibLib.SomethingLibrary.2" should exist in the registry in a ProgID key, if it doesn't your CreateObject won't work.
I won't cover the cases where you haven't registered the activeX component as that is covered elsewhere.
But if you search the registry for part of the object name you are looking for, you may find as I did a ProgId containing
"somethinglib.SomethingSite.1"
knowing this I found
Set library = CreateObject("somethinglib.SomethingSite.1")
worked
Now my example is due partly to the version I had installed not matching the documentation, but hopefully this technique may help others.
In order to make your code working, you need to make sure you have System Scripting Runtime installed on your machine.
Here is very good reference for that.

Microsoft Patch 958369 MS08-070 broke my VB6 App (Type Mismatch - dynamically created control)

We upgraded our machines with a microsoft patch listed above and are now having issues with some winsock controls. While moving on to the new component library there were two issues that we faced:
We are creating a Winsock control dynamically using Form.Controls.Add(...). With the new dlls it gave us a run time error 731 stating that we needed to add the license.
This issue was resolved by adding a line License.Add(PrgID of the control) before adding the control.
Now the issue is when we try setting this control to an object of type mWinsock we get a runtime error Type Mismatch. Any thoughts?
Take a look at "Description of the cumulative update rollup for the Visual Basic 6.0 Service Pack 6 Runtime Extended Files."
http://support.microsoft.com/kb/957924/
This December 30, 2008 update should remove and replace the faulty Dec 9 security update. It appears to deal with both 926857 and 957924.
958369 seems to be a Visual FoxPro KB article for the same faulty update (Dec 9). VFP uses many VB controls.
You may need to add the control to the toolbox so that the VB6 project and form has a proper reference to it. You will need to do this even if you don't actually have it on the form at design time.
With the reference VB may not have all the information needed to resolve the methods and properties of the control at run-time
Since the interface signatures have changed, you will have to remove the component reference from the project, save and close VB6 completely, unregister the old control, register the new version from the patch, reopen your project and add the component back in. If you do this you'll most likely lose support for machines that don't have the patch installed (or you will have to install it as part of your installation package)
Of course, you can always declare the reference "As Object" if it's easier but your performance will drop a bit and you will lose support for WithEvents
I encountered a similar issue when dynamically creating non-intrinsic controls in VB6. Perhaps Winsock is no longer considered intrinsic. Try declaring your variable as VBControlExtender instead of Winsock, as follows:
Option Explicit
Dim WithEvents objExt As VBControlExtender
Private Sub LoadControl()
Licenses.Add "MSWinsockLib.Winsock", "xydsfasfjewfe"
Set objExt = Controls.Add("MSWinsockLib.Winsock", "myCtl")
End Sub
Private Sub extObj_ObjectEvent(Info As EventInfo)
' Program the events of the control using Select Case.
Select Case Info.Name
Case "DataArrival"
' Do stuff
End Select
End Sub
See this MSDN article for more information.

Resources