vba - How to get the version number of an Excel workbook? -


i have excel book that's versioned in sharepoint document library, can go file tab , see versions like:

19.0: 11/10/2014 1:15 pm xyz\tkl2 17.0: 10/12/2014 3:54 pm xyz\tkl2 14.0: 10/11/2014 2:23 pm xyz\92jf 

i want retrieve recent version number, in case 19.0. i've tried using following code:

sub getversions()  dim docversions documentlibraryversions dim dversion documentlibraryversion  set docversions = thisworkbook.documentlibraryversions  each dversion in docversions     debug.print dversion.index     debug.print dversion.comments     debug.print dversion.creator     debug.print dversion.modified     debug.print dversion.modifiedby     debug.print dversion.application next  end sub 

this every property seems possible regarding particular document version. none of these properties retrieve actual version number; e.g., .index retrieve 1, 2, , 3 these versions. there way actual version number?

you can information opening historical version of file, , filename filename.xlsx, versionxx.yy:modified date, xx.yy version number in major.minor format.

i've put code used below. puts version name in column h of sheet opens. it's got little error checking in, not enough use straight off. importantly, assumes spreadsheet it's pasted in spreadsheet open. you'll want have file want version numbers of closes, too.

function fcheckversions(stfilename string) boolean ' ' stfilename full url document in document library. ' dim wb excel.workbook dim versionworksheet excel.worksheet dim dlvversions office.documentlibraryversions dim dlvversion office.documentlibraryversion dim oldversion excel.workbook dim stextension string dim iposext long  virow = 3 thisworkbook.worksheets("index").cells(virow, 1) = stfilename  if workbooks.cancheckout(stfilename) = true     set wb = workbooks.open(stfilename, , true)     set dlvversions = wb.documentlibraryversions     if dlvversions.isversioningenabled = true         thisworkbook.windows(1).visible = false         thisworkbook.worksheets("index").cells(virow, 3) = "num"         versions = " & dlvversions.count"         on error goto versionfailed:         each dlvversion in dlvversions             thisworkbook.worksheets("index").cells(virow, 4) = "version: " & dlvversion.index             thisworkbook.worksheets("index").cells(virow, 5) = "modified date: " & dlvversion.modified             thisworkbook.worksheets("index").cells(virow, 6) = "modified by: " & dlvversion.modifiedby             thisworkbook.worksheets("index").cells(virow, 7) = "comments: " & dlvversion.comments                 set oldversion = dlvversion.open()                 thisworkbook.worksheets("index").cells(virow, 8) = "filename: " & oldversion.name                 if workbooks.count > 2                     workbooks(3).close savechanges:=false                 end if             virow = virow + 1         goto nextversion: versionfailed:         thisworkbook.windows(1).visible = true         msgbox "fail" nextversion:         next dlvversion     end if     wb.close false end if set wb = nothing doevents end function 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -