Consulting

Results 1 to 9 of 9

Thread: Remove "?" from file property

  1. #1
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location

    Remove "?" from file property

    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
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  2. #2
    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

  3. #3
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    @mdmackillopp

    ?
    Quote Originally Posted by Rick Rothstein
    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-...ext-chr63.html
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  4. #4
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    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
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  5. #5
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    Try using this instead:

                PicDim = Replace(Replace(PicDim, ChrW(8234), ""), ChrW(8236), "")
    Be as you wish to seem

  6. #6
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Forgot all about those extra characters and there are two different ones!
    PicDim = Replace(Replace(PicDim, ChrW(8234), ""), ChrW(8236), "")
    Many thanks
    MD
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  7. #7
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Thanks all.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  8. #8
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    @Sam
    Missed yours at first, I'll save that in my Library.

    @ Yasser
    Now you know, things are not always as they appear!
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  9. #9
    Thanks a lot sir
    I am still learning from all of you and it is honor to be a member within this great forum

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •