I am writing a PropertyPage for Outlook using VB6. This is implemented as a VB6 OCX.
When running in a newer version of Outlook (like 2007) on XP (or newer), my dialog looks weird because it doesn't have XP look and feel. Is there a way to do this?
Preferably without adding a manifest file for Outlook.exe.
I think you're right to avoid using a manifest. Unfortunately the standard well-known hacks to support XP themes from VB6 rely on manifests. This MSDN article on developer solutions for Outlook 2007 warns that providing your own manifest for Outlook 2007 might cause it to hang.
I don't think you can do it in VB6 ... those controls are going to look like what they look like. You can, however, create your property pages with Visual Studio .NET and Visual Basic .NET and get the XP, 2007 and Vista look and feel. It's a bit of a change from what you're doing, but you're really behind the times developing with VB6 anyway. More details on how to do that are here and the office developer center.
Not that I know of using VB6
If you can use .NET instead - one way is WPF. I saw earlier an example on code-project.
Here's the link
Edit: And another tool to assist here
This is what I do in all of my VB6 Apps, only ever tested in a standalone EXE so not sure if it will work as an OCX.
Private Type tagInitCommonControlsEx
lngSize As Long
lngICC As Long
End Type
Private Declare Function InitCommonControlsEx Lib "comctl32.dll" _
(iccex As tagInitCommonControlsEx) As Boolean
Private Const ICC_USEREX_CLASSES = &H200
Public Function InitCommonControlsVB() As Boolean
On Error Resume Next
Dim iccex As tagInitCommonControlsEx
' Ensure CC available:
With iccex
.lngSize = LenB(iccex)
.lngICC = ICC_USEREX_CLASSES
End With
InitCommonControlsEx iccex
InitCommonControlsVB = (Err.Number = 0)
On Error Goto 0
End Function
Public Sub Main()
InitCommonControlsVB
'
' Start your application here:
'
End Sub
Create a file similar to this: http://pastebin.com/f689388b2
Then you add the manifest file to your resource file as type RT_MANIFEST (24)
I can't quite remember if that's all you need to do as I always just use the same pre-made .res file now.
Source: http://www.vbaccelerator.com/home/vb/code/libraries/XP_Visual_Styles/Using_XP_Visual_Styles_in_VB/article.asp
Related
I am getting the error that appears in the title and I already check the security settings, I have everything enabled and the Add-in is signed. I put the screenshot of how I have the options. If I have everything enable why it can give security problems?
I am using windows 8 and office 365. And the add-in that is not working is a powerpoint add-in. I try also some solutions that appears in this thread but no one works for me: http://social.technet.microsoft.com/Forums/office/en-US/0b385af0-9856-4cfb-bc48-3369c3ce2ace/when-opening-ms-word-the-macro-cannot-be-found-or-has-been-disabled-because-of-your-macro-security?forum=officeitproprevious
I had the EXACT same problem with an addin which I developed for Powerpoint many years ago and now ran on some computers at my new company, but not others.
The support couldn't help me and Google couldn't really help me, but this thread came closest to describing my situation.
The only common denominator I eventually found was that 32-bit Office could run the addin, but not 64-bit.
So my solution was to go through the VBA source code and replace my declaration variables according to this Microsoft post:
https://msdn.microsoft.com/library/gg264421.aspx
Maybe that could help you as well?
Create a simple PowerPoint presentation and save it as pp_HelloWorld.pptx
Add the following VBA procedure
Option Explicit
Sub sbHelloWorld()
MsgBox "Hello World!"
End Sub
to a module in this presentation and save it as pp_HelloWorld.pptm
Close and reopen this presentation pp_HelloWorld.pptm and the macro will work from the Developer > Macros > Run option
Put the following custom ribbon code
<mso:customUI xmlns:mso='http://schemas.microsoft.com/office/2009/07/customui'>
<mso:ribbon>
<mso:qat/>
<mso:tabs>
<mso:tab id="mso_c1.2A492F1" label="New Tab">
<mso:group id="mso_c2.2A492F1" label="New Group" autoScale="true">
<mso:button id="sbHelloWorld" label="sbHelloWorld" imageMso="ListMacros" onAction="sbHelloWorld" visible="true"/>
</mso:group>
</mso:tab>
</mso:tabs>
</mso:ribbon>
</mso:customUI>
into a file called PowerPoint.officeUI
and put this file in the folder
C:\Users<username>\AppData\Local\Microsoft\Office
(this may be hidden initially)
Close and reopen this presentation pp_HelloWorld.pptm and the macro will work from the Developer > Macros > Run option
The macro will not work from the macro button New Tab > sbHelloWorld and gives the message -
"The macro cannot be found or has been disabled because of your Macro security settings"
Next Clear the Trusted Documents -
Developer > Macro Settings > Trusted Documents > Clear
The macro now works from the macro button New Tab > sbHelloWorld.
This works on Windows 10 with Office 365
I found that this happens when normal.dotm has become corrupt. So the best and quickest solution is to restore the normal.dotm from a recent backup.
I am using OSVERSIONINFO to check the OS in my vb6 application. But i am not able differentiate between windows 7 and windows server 2008 R2 because they have same version number,dwMajorVersion and dwMinorVersion. So how to differentiate between these. I think it can be done in vb.net using some other method. But how it can be done in vb6?
As Xearinox noted in the above comment, OSVERSIONINFOEX returns more information.
In particular, you can examine wProductType to determine whether VER_NT_WORKSTATION (0x0000001) is set or not. If it is, the machine is running a client OS, otherwise, server.
The chart in the remarks section of the OSVERSIONINFO MSDN entry even has a column which points out detecting the various OS's using that struct item.
Right Click On Tool Bar > Components And Add > Microsoft SysControl 6.0.
Double Click The SysInfo Button to Add on Form and use this code
Private Sub Form_Load()
Dim HancyRockz as string
HancyRockz = "OsVersion :- " & SysInfo1.OSVersion & " / Built " & SysInfo1.OSBuild
Text1.Text=HancyRockz
End Sub
I've dropped the VB6 MSCOMM32.OCX (Microsoft Comm Control 6.0 (SP6)) on to a VBA form. I had to apply a Microsoft Security Update KB926857 to VB6 to get the control to drop on the form because a Windows Update set a kill bit on the older version.
When I look at the object's events in VBA I do not have "OnComm" available. I can get it in VB6 by double clicking its icon (a phone) but not in VBA. Importing it in Delphi shows OnComm as the only event handler.
I know the control is registered properly and licensed.
I've done it a couple of years ago with the older control, but has anybody done this lately?
Available Events: OnEnter, OnExit, OnGetFocus, OnLostFocus & OnUpdated
I discovered independently that HK1's suggestion was correct. I created an event handler that looked like this
Private Sub MSComm1_OnComm()
Nothing needed to be done to the object properties to link it to the routine.
In the form load event I placed an MSCOMM1.PortOpen = True. I scanned a bar code and presto it worked.
Why this is treaded differently than other events I do not know and how/where it is documented is a mystery.
This Microsoft site has helpful information on handling the data properly and is what I used for the test.
http://support.microsoft.com/kb/194922
I'm having an issue referencing public procedures of User Controls that I've created within a VB6 project.
A simple example (exe), I have a form with a button and a user control:
Option Explicit
Private Sub Command1_Click()
UserControl1.updateMessage ("TIME NOW: " & DateTime.Time)
End Sub
The User Control code is as follows:
Option Explicit
Public Sub updateMessage(ByVal newMessage As String)
Label1.Caption = newMessage
End Sub
This exe compiles and works fine, and when I'm typing updateMessage in the Form, it appears in the intellisense list with the appropriate requirements. The issue I have is when I'm wanting to "go to the definition" of updateMessage, instead of going to the appropriate section of the code within the User Control, the message always returns with:
"Cannot jump to 'updateMessage' because it is in the library 'Unknown1' which is not currently referenced."
where the numbered suffix of "Unkown1" changes from time to time.
It seems that if there were no reference to this procedure, then it would not appear in the intellisense and the project shouldn't compile. When running this with MZTools (though the error appears regardless of this plug-in being installed), I can go into the updateMessage procedure, and use it to find all procedures calling this function, so the link between the two should exist (although I'm not sure if MZTools just finds using a text-matching pattern).
If anyone out there could shed some light on this matter, it would be very much appreciated, and save this poor VB6 developer a lot of hassle!
I have SP6 installed (build 9782) of VB6 and am running XP SP3 on an HP dx2400.
Yes, this is extremely annoying and I'm convinced it's a bug in VB6. I say this because, if you locate the updateMessage method in the object browser and double-click on it, you are taken to the definition. So, the compiler actually does know where the definition is, it just refuses to take you there with Shift+F2.
In VB6, ActiveX DLL is listed as a project template but in VS 2005+ there is no such thing. Where is my good old ActiveX DLL template? Many thanks in advance.
A couple of concepts; .NET Assemblies are the functional equivalent to ActiveX DLLs in the .NET langauges. .NET Classes and method can be decorated with attribute that have various meaning in different context. A .NET Assembly can be turned into a ActiveX/COM DLL (or OCX) by using various attributes to assign the correct GUIDs.
A basic overview of setting a .NET assembly use COM is here.
Note that do google searches you should include VB6 .NET and COM (not ActiveX). COM generates more hits as it is the underlying technology behind the ActiveX term.
The MSDN article I linked shows a basic COM setup for a .NET Class. The attribute here is the ComClass Attribute.
<ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)> _
Public Class ComClass1
#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String = "6DB79AF2-F661-44AC-8458-62B06BFDD9E4"
Public Const InterfaceId As String = "EDED909C-9271-4670-BA32-109AE917B1D7"
Public Const EventsId As String = "17C731B8-CE61-4B5F-B114-10F3E46153AC"
#End Region
' A creatable COM class must have a Public Sub New()
' without parameters. Otherwise, the class will not be
' registered in the COM registry and cannot be created
' through CreateObject.
Public Sub New()
MyBase.New()
End Sub
End Class
There are other Attributes as well that are especially useful if you trying to subsitute a .NET assembly for an existing COM DLL or OCX. Finally .NET has a lot of different wizards that help you with the tedious details.
Try this: http://msmvps.com/blogs/pauldomag/archive/2006/08/16/107758.aspx
It outlines how to create an activex control and use it in a web page. As far as I know there's really no 'ActiveX' project template since .NET does it differently. However you can make your .Net controls visible to the COM world, which the article above illustrates.
It's not quite clear from you question, but if you want to be able to consume in VB6 (or some other com environment) something created in VS2005, you want to look at the Interop Forms Toolkit. This greatly simplifies interop between VB6 and VS2005. Now if you actually want to distribute those applications, installing what you created becomes a lot more fun (Hints: Don't use the GAC, install the .Net dll in the same directory as your application executable, and learn to use RegAsm.)
If you give a little description what you want to use the ActiveX.dll for (project library or User Control) and what environment you want to use it, more advice can be given.
I don’t know if this is what you are trying to do or not. But if you right click on the Toolbox in Visual Studio, in the popup menu select Choose Item…
When you get the “Choose Toolbox Item” dialog box come up, select the “COM Components” tab and check the COM Component(s) you want to add to the toolbox. I have done this to added the “Windows Media Player” to the toolbox and used it in a C# Winform.
From this dialog you can access any COM, OCX or ActiveX control loaded on you system.