How do I add this code? sets resolution of web cam

rattman

New Member
Joined
Nov 3, 2006
Messages
32
Hello,
I got this piece of code off a forum here. It allows me to take a picture from a web cam inside Excel and save it to my C drive. The problem is that the resolution is so low I cannot use it for its purpose. The company that created the camera sent me this piece of code but I cannot figure out how to insert it into the existing script and make it work.
I was hoping someone here could tell me how to make it work.

Working code from here ---------------------------------------------------------
Sub TAKE_PIC()

Dim tempfile As String
Dim mydevice As WIA.Device
Dim item As WIA.item
Dim imfile As WIA.imagefile
Dim Commondialog1 As WIA.CommonDialog
'put the path and name for the location of your temp file here.
tempfile = ("c:\filename.jpg")
'the next 4 lines deletes the old temp file if it exists
Set filesystemobject = CreateObject("Scripting.FileSystemObject")
If filesystemobject.fileExists(tempfile) Then
Kill (tempfile)
End If
'the next two lines set up the configuration

Set Commondialog1 = New CommonDialog
Set mydevice = Commondialog1.ShowSelectDevice
Set item = mydevice.ExecuteCommand(wiaCommandTakePicture) 'instructs the camera to take the picture
Set imfile = item.Transfer 'transfers the picture from the camera
'this line saves the picture to a specified file
imfile.SaveFile (tempfile)
'this sets the picture on the form to show the new picture
Exit_btnTakePicture_click:
Set mydevice = Nothing
Set item = Nothing
Exit Function
Err_btnTakePicture_click:
MsgBox Err.Description, vbOKOnly + vbCritical, "Error Taking Picture"
Resume Exit_btnTakePicture_click

End Function

--------------------------------------------------------------------------
Email of line to insert:
Please try this function: SetVideoFormat
Function SetVideoFormat (width As Long, height As Long) As Boolean

Can anybody tell me how to insert these lines?
Thanks
Rattman
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Forum statistics

Threads
1,214,788
Messages
6,121,580
Members
449,039
Latest member
Arbind kumar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top