PDA

View Full Version : [SOLVED] Excel VBA to change properties of non-Excel file



Anne Troy
07-04-2005, 11:36 AM
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. :)

mark007
07-22-2005, 02:56 PM
Interesting concept, might take a look if I get some free time. That is a big if though!

:)

Ivan F Moala
07-23-2005, 03:29 AM
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

Anne Troy
07-23-2005, 07:20 AM
Posted, but with Ivan's link. :)