I have located the whole net and only could find out some coding for C#, VBscrpit, VBproject etc but not any in VBA and could work. (In fact, I got one VBA coding but not working indeed). Please help!!
I have located the whole net and only could find out some coding for C#, VBscrpit, VBproject etc but not any in VBA and could work. (In fact, I got one VBA coding but not working indeed). Please help!!
Please post the snippet of code you have found so we can begin to assist from there
Remember To Do the Following....
Use [Code].... [/Code] tags when posting code to the thread.
Mark your thread as Solved if satisfied by using the Thread Tools options.
If posting the same issue to another forum please show the link
Here comes the coding ! Thanks!
Sub command1__Click() Dim strFile As String 'filename Dim strFileType As String 'TIF Mark Dim iffsetIFD As Long ' first IFD deviation value Dim iCountDE As Integer 'DE value Dim lWidth As Long 'width of the TIF Dim lHeight As Long 'Heigh of the TIF Dim Temp1 As Integer, Temp2 As Long, i As Integer, k As Integer strFile = "D:\1.tif" Open strFile For Binary As #1 strFileType = String(2, 0) Get #1, , strFileType ' get TIF mark If strFileType <> "II" And strFileType <> "MM" Then Close #1: Exit Sub Get #1, , Temp1 ' get version Get #1, , iffsetIFD ' get first IFD deviation value Seek #1, iffsetIFD + 1 ' set the next position as first IDF deviation value + 1 Get #1, , iCountDE ' get DE value from the first IDF k = 0 For i = 1 To iCountDE Get #1, , Temp1 ' get property marked number If Temp1 = 256 Then ' if width Get #1, , Temp1 'abandon Get #1, , Temp2 'abandon Get #1, , lWidth k = k + 1 ElseIf Temp1 = 257 Then ' if height Get #1, , Temp1 'abandon Get #1, , Temp2 'abandon Get #1, , lHeight k = k + 1 Else ' else abandon those data Get #1, , Temp1 Get #1, , Temp2 Get #1, , Temp2 End If If k = 2 Then Exit For Next i Close #1 Debug.Print "Width:" & lWidth & vbCrLf & "Height:" & lHeight End Sub
Works fine with Excel 2003:Try using: MsgBox "Width:" & lWidth & vbCrLf & "Height:" & lHeight instead of: 'Debug.Print "Width:" & lWidth & vbCrLf & "Height:" & lHeight
The problem seems not due to that, I have tried and the program exit when it firstly gone through this statement located at the 12th row of the function!!
If strFileType <> "II" And strFileType <> "MM" Then Close #1: Exit Sub
Sorry! IT WORKS WELL now. I save the file in the wrong location! Thanks!!
Hi,
I'm new.
I tried the code with MsgBox substitution.
The report was both Height and width = 0
But if I "hover" over the file name it reports dimensions = 4223x2885.
The test tif file is valid in the sense that Photoshop Elements will open and display it.
Is there an update to tif specs since this code was posted?
How else can I help you to help me?
Thanks
Still works great with Excel 2K3.
W7 (64bit) isn't the problem.
No problem with Excel 2K10, the macro works.
You can open the TIF file with NotePad and look at the first two characters, if they are II the macro will show the size, if they are MM the macro shows 0 x 0.
I think richyfrog's code needs some other amending.
I tried several tif files. Unfortunately they all reported strFileType = MM
Here are typical results
strFile matches my selected file path/name
strFileType = MM
Version = 10752 ( whatever that means)
1stIFDDevValue = 134217728 (ditto)
iCountDE = 0 ( which jumps out
Apparently all who reported it works had a file with strFileType = II
Can anyone help with mods for a Type MM file?
Or point to a tutorial where I can learn about Version, 1stIFDDevValue,and iCountDE ?
PS.. Notepad shows it clearly........MM.....and Width and Height.
HELP?