PDA

View Full Version : read Tag property without opening file



samuelimtech
05-05-2016, 03:25 AM
hi all,

i think the title says it all but for further clarification..

i have a spreadsheet located C:\Users\samuel.brierley\Desktop\Timesheet Dev\Timesheet.xlsm.

the spreadsheet has been given the tag V2

i want another spreadsheet to read that tag and assign it to a variable.

thanks all

Paul_Hossler
05-05-2016, 07:28 AM
the spreadsheet has been given the tag V2


How did you do that? And what exactly is the 'tag' field called? Is it a document property?

samuelimtech
05-05-2016, 07:35 AM
if you press file all the properties are on the right, Tag is a predefined document property

mancubus
05-05-2016, 07:58 AM
?


Msgbox ThisWorkbook.BuiltinDocumentProperties("Tag")

GTO
05-05-2016, 08:23 AM
Hi there,

Without opening the file, I think you may wish to try Shell, NameSpace, GetDetailsOf. I copied (slightly modified) from Here (https://msdn.microsoft.com/en-us/library/windows/desktop/bb787870(v=vs.85).aspx)

In a Standard Module:



Option Explicit

Function fnGetDetailsOfVB()
Dim objShell
Dim objFolder
Dim n As Long

Set objShell = CreateObject("shell.application")
Set objFolder = objShell.Namespace("C:\Users\stumpm\Desktop\")

If (Not objFolder Is Nothing) Then
Dim objFolderItem

Set objFolderItem = objFolder.ParseName("ADP No Approval.xlsm")

If (Not objFolderItem Is Nothing) Then
For n = 1 To 288
Debug.Print n; objFolder.GetDetailsOf(objFolderItem, n)
Next
End If

Set objFolderItem = Nothing
End If

Set objFolder = Nothing
Set objShell = Nothing

End Function


Someplace (not well researched, just a quick look) I read that iColumn is now (or more recently) 1 to 288, but regardless of accuracy of that, I think you just need 18.

Hope that helps,

Mark

Paul_Hossler
05-05-2016, 05:03 PM
Mark -- I had this link buried in a file

http://www.forums.purebasic.com/english/viewtopic.php?f=13&t=56904


It varies from 0 to 297 and depends on Windows version (thank you Mr. Gates) (Win 10 in not included in the list)


Tag = 18 in all versions except XP and 2000


I recall (I think) that there was way to enumerate the item name also, but couldn't find it


Edit -- Found it



Sub fnGetDetailsOfFields()
Dim objShell
Dim objFolder
Dim n As Long

Set objShell = CreateObject("shell.application")
Set objFolder = objShell.Namespace("C:\Users\Daddy\Desktop\")

On Error GoTo Oops
For n = 0 To 297
Debug.Print n; objFolder.GetDetailsOf(objFolder.Items, n)
Next n
Oops:

Set objFolder = Nothing
Set objShell = Nothing

End Sub


So if there's a chance you're running in different O/S, you might have to check the field name also and then get the value

GTO
05-06-2016, 03:05 AM
Hi Paul,


...It varies from 0 to 297 and depends on Windows version (thank you Mr. Gates) (Win 10 in not included in the list)...

Wow! What a hodge-podge of different values depending on OS version. :eek::crying:

Well thank you for catching my error in starting points, I am sure I misread whatever it was I saw. I certainly would include checking the field name as you suggest.

Mark

PS. - Is it just me, or does Windows develop feelings at #9? Perceived Type?

Paul_Hossler
05-06-2016, 05:55 AM
(1) Wow! What a hodge-podge of different values depending on OS version. :eek::crying:

(2) Well thank you for catching my error in starting points, I am sure I misread whatever it was I saw. I certainly would include checking the field name as you suggest.

Mark

(3) PS. - Is it just me, or does Windows develop feelings at #9? Perceived Type


(1) - Yes indeed

(2) - Entry 0 was just the name which is needed anyway. "Tags" = 18 back to Vista, but not XP, so you're probably safe (depending on how much variety there is among the user population)
LOTS of changes from Vista to Win 7


(3) - I've always suspected that since it seems to know when I'm mad at it or under pressure to get something done