Consulting

Results 1 to 4 of 4

Thread: Excel VBA to change properties of non-Excel file

  1. #1
    Site Admin
    The Princess
    VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location

    Excel VBA to change properties of non-Excel file

    Can we change the properties of "any" file?

    http://answers.google.com/answers/threadview?id=539403

    If we can get an answer in the kb shortly, I can post a link to it. We get lots of hits from there that way.
    ~Anne Troy

  2. #2
    BoardCoder
    Licensed Coder VBAX Expert mark007's Avatar
    Joined
    May 2004
    Location
    Leeds, UK
    Posts
    620
    Location
    Interesting concept, might take a look if I get some free time. That is a big if though!

    "Computers are useless. They can only give you answers." - Pablo Picasso
    Mark Rowlinson FIA | The Code Net

  3. #3
    VBAX Contributor Ivan F Moala's Avatar
    Joined
    May 2004
    Location
    Auckland New Zealand
    Posts
    185
    Location
    I would just use the Windows functionality to change the properties.
    This worked for me in WinXp.

    '---------------------------------------------------------------------------------------
    ' Module    : basMain
    ' DateTime  : 02/09/2004 22:23
    ' Author    : Ivan F Moala
    ' Purpose   :
    '---------------------------------------------------------------------------------------
    Option Explicit
    
    '//
    Public Declare Function ShellExecute _
        Lib "shell32.dll" _
            Alias "ShellExecuteA" ( _
                ByVal Hwnd As Long, _
                ByVal lpOperation As String, _
                ByVal lpFile As String, _
                ByVal lpParameters As String, _
                ByVal lpDirectory As String, _
                ByVal nShowCmd As Long) _
    As Long
    
    '// Properties API
    Private Type SHELLEXECUTEINFO
        cbSize       As Long
        fMask        As Long
        Hwnd         As Long
        lpVerb       As String
        lpFile       As String
        lpParameters As String
        lpDirectory  As String
        nShow        As Long
        hInstApp     As Long
        lpIDList     As Long
        lpClass      As String
        hkeyClass    As Long
        dwHotKey     As Long
        hIcon        As Long
        hProcess     As Long
    End Type
    
    Private Declare Function ShellExecuteEx _
        Lib "shell32.dll" ( _
            Prop As SHELLEXECUTEINFO) _
    As Long
    
    Public Function fnGetPropDlg(strFilepath As String) As Long
    Dim Prop As SHELLEXECUTEINFO
    
    With Prop
        .cbSize = Len(Prop)
        .fMask = &HC
        .Hwnd = 0&
        .lpVerb = "properties"
        .lpFile = strFilepath
    End With
    
    fnGetPropDlg = ShellExecuteEx(Prop)
    
    End Function
    called with

    Private Sub CommandButton1_Click()
    Dim vFile As Variant
    
    vFile = Application.GetOpenFilename
    If TypeName(vFile) = "Boolean" Then Exit Sub
    
    fnGetPropDlg CStr(vFile)
    
    End Sub
    Kind Regards,
    Ivan F Moala From the City of Sails

  4. #4
    Site Admin
    The Princess VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    Posted, but with Ivan's link.
    ~Anne Troy

Posting Permissions

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