How to show zoomed out web browser in vb6.0 - vb6

This is the code am using for zoomed out web browser
Const OLECMDID_OPTICAL_ZOOM = 63
Const OLECMDEXECOPT_DONTPROMPTUSER = 2
Web1.ExecWB OLECMDID_OPTICAL_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, CLng(35), vbNull
when i use the code i get the following runtime error:
-2147221248 (80040100): Automation Error
Any ideas?
Edited:
I use the code given by you. It works fine in debug mode once i take exe and run it shows the following error.

This only works once a document has loaded, then seems to persist for subsequent navigation.
If you attempt to change the optical zoom when there is no DOM document, error 80040100 occurs.
The code below simply sets zoom initially at the appropriate time;
Private Const OLECMDID_OPTICAL_ZOOM As Long = 63
Private Const OLECMDEXECOPT_DONTPROMPTUSER As Long = 2
Private mblHasSetZoom As Boolean
Private Sub Form_Load()
web1.Navigate2 "http://www.google.com"
End Sub
Private Sub web1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If Not mblHasSetZoom Then
web1.ExecWB OLECMDID_OPTICAL_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, 35&
mblHasSetZoom = True
End If
End Sub

Related

Can i add custom icon to "outlook" item?

I am trying to add a custom icon to outlook items (inbox items list) using officejs addon for outlook.
If this is not possible with officejs then how can I achieve this using Exchange service or with any other tool or library?
You can change the icon, however, you have a choice of icons. You would need to use C# or VB.NET (eg VSTO Outlook-addin) or VBA.
I could not find a list of icon values you can use but here is an image of an old list - in case the link gets lost.
Source of the image and also partly answering your question.
To change the icon you need to use the MailItem.PropertyAccessor
Couple of Examples Const (these are hex values but you can use a Long as well)
Const OL_PHONE = &H15D
Const OL_GROUP = &H202
Const OL_NOTE = &H1BD
Const PR_ICON_INDEX As String = "http://schemas.microsoft.com/mapi/proptag/0x10800003"
Using the below helper methods
'use the Get to see the value of an icon
'prior to this code you would need to get a reference to an Outlook mailitem
Dim res As New Object
GetExtendedPropertyValue(oMailItem, PR_ICON_INDEX, res)
'check the value of res or call Hex(res) to see its hex value
'here you can set the icon eg OL_GROUP etc
SetExtendedPropertyValue(oMailItem, PR_ICON_INDEX, OL_PHONE)
Couple of helper methods I have made
Private Function GetExtendedPropertyValue(ByVal aMailItem As Outlook.MailItem, ByVal aProperty As String, ByRef res As Object) As Boolean
Dim oPropAcc As Outlook.PropertyAccessor = Nothing
Try
oPropAcc = DirectCast(aMailItem.PropertyAccessor, Outlook.PropertyAccessor)
res = oPropAcc.GetProperty(aProperty)
Return True
Catch ex As System.Exception
'Put your own logging here
Finally
If Not oPropAcc Is Nothing Then
Marshal.ReleaseComObject(oPropAcc)
oPropAcc = Nothing
End If
End Try
Return False
End Function
Private Function SetExtendedPropertyValue(ByVal aMailItem As Outlook.MailItem, ByVal aProperty As String, ByVal value As Integer) As Boolean
Dim oPropAcc As Outlook.PropertyAccessor = Nothing
Try
oPropAcc = DirectCast(aMailItem.PropertyAccessor, Outlook.PropertyAccessor)
oPropAcc.SetProperty(aProperty, value)
Return True
Catch ex As System.Exception
'Put your own logging here
Finally
If Not oPropAcc Is Nothing Then
Marshal.ReleaseComObject(oPropAcc)
oPropAcc = Nothing
End If
End Try
Return False
End Function
These three examples look like this
The PR_ICON_INDEX PidTagIconIndex Canonical Property can be found here and note that they do say
This property, if it exists, is a hint to the client. The client may ignore the value of this property.
However this does not seem to be the case.
Of course the icon change will not be permanent. If the user forwards the emails or replies then it would be changed.
EDIT
By the way here is a nice way to find out the possible icons. Make a temp folder and copy a rubbish email into this folder 2048 times. Then run this code
Public Sub PrIconIndex()
USE THIS MACRO WITH CARE!
Dim objItems As Items
Dim mail As MailItem
Dim i As Integer
Set objItems = Application.ActiveExplorer.CurrentFolder.Items
For i = 1 To 2048
Set mail = objItems(i)
Call mail.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x10800003", i)
mail.Body = CStr(i)
mail.Save
Next
End Sub
The above come from this forum link
Currently the feature to add a custom icon to outlook items is not there. We track Outlook add-in feature requests on our user-voice page. Please add your request there. Feature requests on user-voice are considered, when we go through our planning process.

Excel UserForm button click slow response time when clicked fast

I have a VBA UserForm in Excel, with very simple code. It displays a collection (a dictionary, actually) of objects, one at a time, with buttons for "first, previous, next, and last". Everything works great, but if I were to continually click the next button to go through the items, I have to click it slowly (roughly once a second). If I click any faster, the click is ignored. For example, if I click four times over two seconds, it will only 'register' the first and third click and advance twice, instead of four times.
Below is example code for the 'next' button (and the other applicable pieces of code in the userform module):
Private dQIDs As Dictionary
Public Sub TransferQIDs(ByVal dIncomingQIDs As Dictionary)
Set dQIDs = dIncomingQIDs
End Sub
Private Sub bNext_Click()
Call LoadQID(CLng(lIndex.Caption) + 1)
End Sub
Private Sub LoadQID(lQID As Long)
Dim QID As cQID
Set QID = dQIDs(lQID)
lIndex.Caption = lQID
lItems.Caption = "Viewing new QID " & lQID & " of " & dQIDs.Count
Me.tQID = QID.lQID
Me.tTitle = QID.sTitle
Me.tVID = QID.sVendorID
Me.bOS = QID.bOSPatch
Me.bApp = Not QID.bOSPatch
Me.bPrev.Enabled = Not (lQID = 1)
Me.bFirst.Enabled = Not (lQID = 1)
Me.bNext.Enabled = Not (lQID = dQIDs.Count)
Me.bLast.Enabled = Not (lQID = dQIDs.Count)
End Sub
Any ideas?
Personally I would just disable to button while content is loaded.
Private Sub bNext_Click()
Dim b1 As Button
Set b1 = ActiveSheet.Buttons("LoadQID")
REM or Me.LoadQID
b1.Font.ColorIndex = 15
b1.Enabled = False
Application.Cursor = xlWait
Call LoadQID(CLng(lIndex.Caption) + 1)
b1.Enabled = True
b1.Font.ColorIndex = 1
Application.Cursor = xlDefault
End Sub
Reason why this happens is that accessing a single object takes quite a bit of time in Excel. This way if you can click it will be registered.
Alternatively you can toggle UI update with:
Application.ScreenUpdating = False
Application.ScreenUpdating = True
windows is checking for a doubleclick. so if you click fast it registers a doubleclick.
2 options. increase you doubleclick speed in the windows mouse settings
or make a doubleclick event

Unbound imagecontrol ONLY show First image when imagelink is added in a 1:N relation

Background:
Entry is via a subform for adding/showing/linking images.
I do not want to store the image files within my DB, the image folder is separate. The DB will grow rather large in time.
I have created a click-control enabling a popup for user to browse and click on the imagePATH to be added in a Bound Textfield (called Bildadress, no not misspelled in My country, Grin ) in the subform.
See code below.
Then I add a new unbound Image-control and specify its Controlsource = the Textfield mentioned above.
For the firs image this works wonderful, but for the following the Image-control returns NULL (not show att all). The data in the Textfield updates as it should.
Will the 2nd stage only work in a 1:1 relationship OR can I (with your help) use VBA code to make this work?
OPTIMAL would be to get this to work and also a 2nd Bound Textfield just displaying the actual image file name. .
I hope someone out there have encountered this problem who also didnt want to use Attachment to store the files within the databae.
CODE:
Private Sub AddFilePath_Click()
Call Selectfile
End Sub
Public Function Selectfile() As String
Dim Fd As FileDialog
Set Fd = Application.FileDialog(msoFileDialogOpen)
With Fd
.AllowMultiSelect = False
.Title = "Välj önskad fil"
If .Show = True Then
Selectfile = .SelectedItems(1)
Me.Bildadress = Selectfile
Else
Exit Function
End If
End With
Set Fd = Nothing
End Function
If you use a bound textbox that holds the image-path then you can use
Me.Imagecontrol.Picture = Me.BoundTextControl.Value
to load the picture into an unbound image control. In your case that would be something like
If .Show = True Then
Me.Bildadress.value = .SelectedItems(1)
Me.Bild.Picture = Me.Bildadress.value
Else
It would be best to also load the respective picture in the OnCurrent Event.
Private Sub Form_Current()
Me.Bild.Picture = Me.Bildadress.value
End Sub
However, keep in mind that access is a one-file-database and you break that paradigm when using links to external files where the files would belong into the DB.

How to use PageSetup in vbs?

I tried to implement PageSetup class
With objWb.Worksheets("test")
.PageSetup.RightMargin=0.5 'executes okay
.PageSetup.PaperSize = xlPaperLegal 'throws an error
.PageSetup.Orientation = xlLandscape 'throws an error
End With
ERROR: Unable to set the PaperSize property of the PageSetup class
although .PageSetup.RightMargin=0.5 executed fine. Why don't the next two lines execute?
How to se paperLegal and landscape ?
Those are Excel constants. You'll need to define them yourself. Use the Object Browser within Excel's VBA screen (hit ALT+F11 to get to VBA, then hit F2 to bring up the Object Browser).
Const xlPaperLegal = 5
Const xlLandscape = 2

How to navigate using WebBrowser Control

How to navigate using WebBrowser Control? I want to open a C:\file1.html... an example code would be appreciated.
The VB code you have is correct, that is an error with the javascript on the page you are loading, so you can use:
Private Sub Command1_Click()
WebBrowser1.Navigate2 "C:\file1.html"
End Sub
But in Form_Load set silent mode, eg:
Private Sub Form_Load()
WebBrowser1.silent = true
End Sub
i first put a webcomponent as mentioned in the post "How do i open a webpage" in vb6 by adatapost
Private Sub Command1_Click()
WebBrowser1.Navigate2 "C:\file1.html"
End Sub
this works but as u click on the button it pops a error..A error has occured on the scirpt of the page , line 6, Error: object expected, url: file:///C:file1/index.html, do u want to continue , yes or NO............................how to come around this error. ??

Resources