Updating file author attribute with vb
I've also tried placing your code into a class module as a function....but, I'm not sure how to get a value returned to use for my form's unbound text box. Nevermind, I found some code from Terry Kreft: Pass the filename and 0 for the creation date 1 for the last access date 2 for the last write date (modified) ************************************************** 'Code Start ************************************************** Private Const OPEN_EXISTING = 3 Public Const INVALID_HANDLE_VALUE = -1 Private Const GET_CREATE_DATE = 0 Private Const GET_LAST_ACCESS_DATE = 1 Private Const GET_LAST_WRITE_DATE = 2 Private Type FILETIME dw Low Date Time As Long dw High Date Time As Long End Type Private Type SYSTEMTIME w Year As Integer w Month As Integer w Day Of Week As Integer w Day As Integer w Hour As Integer w Minute As Integer w Second As Integer w Milliseconds As Integer End Type Private Declare Function File Time To System Time Lib "kernel32" _ (lp File Time As FILETIME, lp System Time As SYSTEMTIME) As Long Private Declare Function File Time To Local File Time Lib "kernel32" _ (lp File Time As FILETIME, lp Local File Time As FILETIME) As Long Private Declare Function Get File Time Lib "kernel32" (By Val _ h File As Long, lp Creation Time As FILETIME, lp Last Access Time _ As FILETIME, lp Last Write Time As FILETIME) As Long Private Declare Function Create File Lib "kernel32" Alias "Create File A" _ (By Val lp File Name As String, By Val dw Desired Access As Long, _ By Val dw Share Mode As Long, By Val lp Security Attributes As Long, _ By Val dw Creation Disposition As Long, By Val dw Flags And Attributes As Long, _ By Val h Template File As Long) As Long Private Declare Function lclose Lib "kernel32" Alias "_lclose" (By Val _ h File As Long) As Long Function File Time Info(In File Name As String, Which Time As Integer) As Date Dim dte Ret As Date Dim h File As Integer Dim Creation Time As FILETIME Dim Last Access Time As FILETIME Dim Last Write Time As FILETIME Dim Local Time As FILETIME Dim Sys Time As SYSTEMTIME On Error Go To File Time Info_err h File = Create File(In File Name, 0&, 0&, 0&, OPEN_EXISTING, 0&, 0&) If h File = INVALID_HANDLE_VALUE Then Err. Date Created Set fso = Nothing Set f = Nothing ---------------- I get a runtime error: "Invalid Procedure Call or Argument" on clicking.
Wouldn't it be useful to be able to edit the contents of an Office 2007 Open XML file from within VBA? I have made the file used in this article available for download: Edit Open Doug Glancy, a colleague of mine, has developed a tool to edit the Ribbon X code in your file without ever leaving Excel.If the file name changes, the new file name is displayed when the field is updated.Fields can be inserted in any kind of text (except tolerances), including text in table cells, attributes, and attribute definitions.For safety reasons a backup copy of the file is made first.Then the file is renamed by appending after the name. The code below (taken from class module cls Edit Open XML) shows how this is done: One of the most basic operations when working with the Open XML package would be changing the XML of a worksheet in the file.Can I use these functions to rebuild a complicated Excel file from scratch?
File thousands of formulas, data tables, named ranges etc and it has been versioned for over 5 years in our company.
Of course we'd want to extract the proper XML from the package based on the information mere mortals know: the sheet's name.
The code shown below extracts the proper r Id (relationship identifier) attribute value as it is listed within the file within the sheets node of that file.
I think the formatting saved with the file is the thing that is occasionally corrupting the file.
I'd need to unzip the calculation workbook, copy the sheets with formulas, datatables and named cells. Thank you Hi Miguel, No, I have no sample code for that. I'm working in a pretty locked-down environment, so can't use the Custom UI editor any more.
The code shown in this article and in the associated download file shows you a way to extract content from the Office 2007 Open XML file format and even enables you to edit parts of the content.