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.
Related
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
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.
First of all, let me myself make the obligatory snarky comment about having to maintain VB5 code: yes, it's pitiful, but can we please just cut to the chase? Thanks.
I am having to revisit some VERY old code that was written in 1998 and which hasn't been touched since 2003. The problem I am having is that I am getting a compile error on this:
Dim ObjCtx As ObjectContext
The VB5 compiler throws a compile error: User-defined type not defined
This is not of course a user-defined type, but is a part of some libary or another. My problem is that I don't know which library I might be missing. The workstation is reconstructed from an old Windows 2000 workstation, and not all libraries may have been installed. I am suspecting that ObjectContext might be a part of some version of ADO (ActiveX Data Objects), of which only v2.1 is currently installed.
Are there any old-timers out there who remember anything about this?
You need to add a reference to your project for "COM+ Services Type Library" (COMSVCS.DLL)
I'm using VB 6.0 and it gives me:
Compile Error:
Can't Find Project or Library
in this sub:
Private Sub MDITimer_Timer()
Dim textStr As String
textStr = Format(Now, "dd-mm-yyyy hh:mm:ss")
StatusBar.Panels(1).Text = textStr
End Sub
I made it like this and the error still was in the Format function (so it is not a StatusBar problem).
Can you tell me what is the Reference that we have to add to use the Format function? Or if a Reference is not needed, what do we have to do to make this work?
Problem's more likely to be the StatusBar (In the Microsoft Windows Common Controls, MSCOMCTL.ocx). Format is built into the VB6 language, you shouldn't need any reference at all.
EDIT Format is in VBA.Strings. I think this is in the "Visual Basic for Applications" reference, MSVBVM60.dll. I thought the VB6 IDE prevented you from unticking the reference.
You probably overloaded Format() with a declaration of the same name. Have you tried calling VBA.Format() instead?
You should also use Format$() to avoid the unnecessary overhead of working with the Variant result Format() returns.
I know this is old but in case someone else comes down this road...
When I had this issue found the real problem was nothing to do with MSVBVM60.dll which as said cannot be disabled as a reference.
What the error is complaining about is that a reference defined in the project is not resolved. It is not saying that the missing reference necessarily has anything to do with the function it is highlighting. What I assume the compiler is doing is sequentially searching the defined references to find the function. During that search it finds one of the references is not resolved (ie the dll or whatever is missing). This causes it to stop the search and give the error.
Reason using VBA.Format helps is that it tells the compiler where to search avoiding the need to scan through all the references.
Solution: check references defined in the project (Project => References) and make sure they are all resolved.
Usually an unresolved reference will have the word 'MISSING:' in front of it. The path shown for the reference is where the project thinks it should be, it does not mean it is there.
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.