Hi Blue,
I believe th new file code works fine,but i am unable to copy the cube and see the new cube with changed filename too. A runtime error of R-70,PERMISSION DENIED comes.
My macro is mentioned in this mail. Basically i want a cube with new name(timestamp) to be generated in a new folder.
Sub Main ()
Dim objTransApp As Object
Dim objModel As Object
Dim strModelPath As String
Dim strLocation As String
Dim strModelSource As String
' *** File Names and Path(s) *****************************************************
strLocation = "C:\Documents and Settings\tcbtr\Desktop\Cognos\Model\Monthly_Sales\"
strModelSource = "SalesModel.pyi"
strModelPath = strLocation & strModelSource
'*** Open model inside Transformer**********************************************
Set objTransApp = CreateObject("CognosTransformer.Application.cer4")
Set objModel = objTransApp.OpenModel(strModelPath)
'*** Clean model and build cubes************************************************
With objModel
.CreateMDCFiles
.Close
End With
' *** Copy the Cubes to the destination
Dim strCubePath As String
' *** Destination Folders*******************************************************
Dim strCognosFolder As String
' *** Cube Names***************************************************************
Dim strCube As String
' *** Set Source Folder Path***************************************************
strCubePath = "C:\Documents and Settings\tcbtr\Desktop\Cognos\Cubes\"
' *** Set Destination Folder Path(s)*******************************************
strCognosFolder = "C:\Documents and Settings\tcbtr\Desktop\Cognos\Refresh_Cube\"
' *** Set Cube Names*************************************************************
strCube = "salescube.mdc"
Dim timestamp,sCubeExtn,newStrCube as String
timeStamp = format(Now,"ddmmyyyy hh:mm:ss AM/PM")
sCubeExtn = ".mdc"
newStrCube = "salescube"
Dim newFileName as String
newFileName = strCubePath & newStrCube & timeStamp & sCubeExtn
' *** Copy Each Cube into the Destination Folders*********************************
FileCopy strCubePath & strCube, strCognosFolder & newFileName
objModel.Close
Set objCube = Nothing
Set objTransApp = Nothing
Set objModel = Nothing
MsgBox "Refreshed Sales Cube has been created"
End Sub
please reply at the earliest. error is thrown at file copy
thanks in advance
regards,
aman