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
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