Change author in excel

Change author in excel

Postby Marc Vanzegbroeck » Thu Jun 21, 2012 10:00 am

Hi,

Is it possible to fill the author, Title and other property-fields of an excel-file via FiveWin?

Thanks

Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Change author in excel

Postby Gale FORd » Thu Jun 21, 2012 12:32 pm

When I do not know how to do something in Excel I record a macro, make the changes, then go back and edit the macro to see how Excel did it.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: Change author in excel

Postby Marc Vanzegbroeck » Thu Jun 21, 2012 1:50 pm

The problem is that a macro doesn't record changing the title or author.

Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Change author in excel

Postby Gale FORd » Thu Jun 21, 2012 3:41 pm

That does make it harder :)
I will check.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: Change author in excel

Postby Marc Vanzegbroeck » Thu Jun 21, 2012 6:55 pm

Hi,

I found on the MicroSoft-site an example how to change the 'Subject'-field it in VBA

Code: Select all  Expand view
Dim properties As Microsoft.Office.Core.DocumentProperties

properties = DirectCast(Globals.ThisDocument.BuiltInDocumentProperties, _
    Microsoft.Office.Core.DocumentProperties)

properties.Item("Subject").Value = "Whitepaper"

 


Do you know how to do this in FWH?

Thanks,
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Change author in excel

Postby anserkk » Fri Jun 22, 2012 12:56 am

Please try the following code. I have not tested this.

Code: Select all  Expand view
oWorkBook:BuiltinDocumentProperties("Author") := cAuthor
oWorkBook:BuiltinDocumentProperties("Title") := cTitle
oWorkBook:BuiltinDocumentProperties("Comments") := cComments


Regards
Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Change author in excel

Postby Marc Vanzegbroeck » Fri Jun 22, 2012 5:54 am

Anser,

Unfortunately it doesn't work. I have this error

Error description: Error Excel.Application:ACTIVESHEET/16389 E_FAIL: _BUILTINDOCUMENTPROPERTIES
Args:
[ 1] = C Test

Stack Calls
===========
Called from: win32ole.prg => TOLEAUTO:_BUILTINDOCUMENTPROPERTIES(0)


Regards,
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Change author in excel

Postby anserkk » Fri Jun 22, 2012 7:55 am

Sorry, I missed Value in the statement.

This is working fine for me.
Code: Select all  Expand view

#include "FiveWin.ch"

Function Main()
   Local oExcel,oWorkBook
   
   oExcel:=CreateObject( "excel.application" )
   oWorkBook:=oExcel:Workbooks:Add()
   
   oWorkBook:BuiltinDocumentProperties("Author"):Value := "Anser K.K."
   oWorkBook:BuiltinDocumentProperties("Title"):Value := "Test Title"
   oWorkBook:BuiltinDocumentProperties("Comments"):Value := "Test Comments"
   
   cFile := 'D:\test.xlsx'
 
   oWorkBook:saveAS( cFile )
   oExcel:Quit()  
   MsgInfo("Done")    

Return Nil

Regards
Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Change author in excel

Postby Marc Vanzegbroeck » Fri Jun 22, 2012 8:36 am

Thanks Anser,

It's working fine now!!

Regards,
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 105 guests