Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
<!--- Set this variable to the full path of your file --->
<cfset thisFile = "C:\test.doc">
<!--- ------------------------------- --->
<!--- Get the file's extension --->
<cfset fileExt = LCase(ListLast(Trim(thisFile), "."))>
<!--- Get the correct class based on the file's extension --->
<cfif VARIABLES.fileExt IS "doc" OR VARIABLES.fileExt IS "dot" OR VARIABLES.fileExt IS "rtf">
<cfset thisClass = "Word.Application">
<cfelseif VARIABLES.fileExt IS "xls">
<cfset thisClass = "Excel.Application">
<cfelseif VARIABLES.fileExt IS "ppt">
<cfset thisClass = "PowerPoint.Application">
</cfif>
<!--- If necessary, create the COM object and put it in the Application scope --->
<cftry>
<!--- First try to connect to an existing object --->
<cfobject type="COM" name="fileObj" class="#thisClass#" action="CONNECT">
<cfcatch>
<!--- There is no existing object, create one --->
<cfobject type="COM" name="fileObj" class="#thisClass#" action="CREATE">
</cfcatch>
</cftry>
<!--- Work in the COM object to get the properties --->
<cfif VARIABLES.fileExt IS "doc" OR VARIABLES.fileExt IS "dot" OR VARIABLES.fileExt IS "rtf">
<cfset docs = fileObj.Documents()>
<cfelseif VARIABLES.fileExt IS "xls">
<cfset docs = fileObj.WorkBooks()>
<cfelseif VARIABLES.fileExt IS "ppt">
<cfset docs = fileObj.Presentations()>
</cfif>
<!--- Open the document --->
<cflock timeout="20" name="openDoc" type="READONLY">
<cfset objNewDoc = docs.open(thisFile)>
</cflock>
<!--- Make this one the active application --->
<cfset activeApp = objNewDoc.Application>
<!--- Make this one the active document --->
<cfif VARIABLES.fileExt IS "doc" OR VARIABLES.fileExt IS "dot" OR VARIABLES.fileExt IS "rtf">
<cfset activeDoc = fileObj.ActiveDocument>
<cfelseif VARIABLES.fileExt IS "xls">
<cfset activeDoc = fileObj.ActiveWorkbook>
<cfelseif VARIABLES.fileExt IS "ppt">
<cfset activeDoc = fileObj.ActivePresentation>
</cfif>
<!--- Get the built in properties --->
<cfset docProps = activeDoc.BuiltInDocumentProperties>
<!--- Create a structure to hold the property/value pairs --->
<cfset sProperties = StructNew()>
<!--- Loop through the properties and add them to the structure --->
<cfloop collection="#docProps#" item="property">
<cfset thisPropName = property.name>
<!--- If a value is not defined it errors out, so try/catch it --->
<cftry>
<cfset thisPropValue = property.Value>
<cfcatch>
<cfset thisPropValue = "">
</cfcatch>
</cftry>
<!--- Add it to the structure --->
<cfscript>StructInsert(sProperties, thisPropName, thisPropValue);</cfscript>
</cfloop>
<!--- Shut down the application --->
<cftry>
<cfset fileObj.Quit(0)>
<cfcatch>
<!--- Sometimes it doesn't work, but only rarely --->
</cfcatch>
</cftry>