PDA

View Full Version : [SOLVED] Remove "?" from file property



mdmackillop
07-17-2017, 04:39 AM
Other than using Mid to shorten the string, I can't seem to get rid of the "?" in the result:
63 - ?140 x 108?
Any suggestions?



Public Sub SquarePics()
Dim PicDim As String
strPath = "C:\Users\Emachine\Pictures\" 'Specify the Image folder name
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(strPath)


For Each f In objFolder.Items
PicDim = objFolder.GetDetailsOf(f, 31)
If PicDim <> "" Then
PicDim = Replace(PicDim, Chr(63), "")
Debug.Print Asc(Left(PicDim, 1)) & " - " & PicDim
End If
Next
End Sub

YasserKhalil
07-17-2017, 05:01 AM
Hello sir
I have tested that and the code already removes "?" from the string



Sub Test()
Dim PicDim As String

PicDim = "63 - ?140 x 108?"
PicDim = Replace(PicDim, Chr(63), "")

MsgBox Asc(Left(PicDim, 1)) & " - " & PicDim
End Sub

mancubus
07-17-2017, 05:25 AM
@mdmackillopp

?

I think you have a Unicode character whose ASCII/ANSI value is greater than 255. Asc cannot see Unicode characters and returns 63 (the question mark) for them. Try using AscW instead of Asc in your code and I think you will get a more meaningful number back from it.
https://www.mrexcel.com/forum/excel-questions/669958-removing-hidden-chr-within-text-chr63.html

SamT
07-17-2017, 05:32 AM
Public Sub WhatAreCharacters()
Dim PicDim As String
strPath = "C:\Users\Emachine\Pictures\" 'Specify the Image folder name
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(strPath)

Dim i as long
Dim X As String
Dim f

For Each f In objFolder.Items
PicDim = objFolder.GetDetailsOf(f, 31)
If PicDim <> "" Then
For i = 1 to Len(PicDim)
X = X & (mid(PicDim, i, 1)) & ": "
X = X & AscW(mid(PicDim, i, 1)) & vbCrLf
Next
MsgBox X
X = ""
End If
Next
End Sub

Aflatoon
07-17-2017, 05:33 AM
Try using this instead:


PicDim = Replace(Replace(PicDim, ChrW(8234), ""), ChrW(8236), "")

mdmackillop
07-17-2017, 05:38 AM
Forgot all about those extra characters:banghead: and there are two different ones!


PicDim = Replace(Replace(PicDim, ChrW(8234), ""), ChrW(8236), "")
Many thanks
MD

mdmackillop
07-17-2017, 05:39 AM
Thanks all.

mdmackillop
07-17-2017, 05:49 AM
@Sam
Missed yours at first, I'll save that in my Library.

@ Yasser
Now you know, things are not always as they appear!

YasserKhalil
07-17-2017, 06:07 AM
Thanks a lot sir
I am still learning from all of you and it is honor to be a member within this great forum