Open excel file and overwrite and check
Open excel file and overwrite and check
(OP)
Hi dear friend or members
I have some values and I want to overwrite excel file before I create path in down.
However I didnot open created file.Also I want to check this file was opened do something.
Thank you for helping.
If strsearch = sname Then
sTemp = sname + " = " + CStr(a(9)) + ", " + CStr(a(10)) + ", " + CStr(a(11))
'Msgbox sTemp
oLocation = "C:\Macro Files\" & partName1 & "." & exportFormat 'before is created
'I want to open again this excel file
'if this file is "open or activated"
' oExcel.Cells(1,1)="NAME" ...
End If
I have some values and I want to overwrite excel file before I create path in down.
However I didnot open created file.Also I want to check this file was opened do something.
Thank you for helping.
If strsearch = sname Then
sTemp = sname + " = " + CStr(a(9)) + ", " + CStr(a(10)) + ", " + CStr(a(11))
'Msgbox sTemp
oLocation = "C:\Macro Files\" & partName1 & "." & exportFormat 'before is created
'I want to open again this excel file
'if this file is "open or activated"
' oExcel.Cells(1,1)="NAME" ...
End If





RE: Open excel file and overwrite and check
If strsearch = sname Then
sTemp = sname + " = " + CStr(a(9)) + ", " + CStr(a(10)) + ", " + CStr(a(11))
Dim Mydirectory As String
Dim MyExtension As String
Dim MyFileName As String
Dim FileCheck As String
Mydirectory = "C:\Macro Files\" 'before is created
MyExtension = ".xls"
MyFileName = Mydirectory + partName1 + MyExtension
On Error Resume Next
FileCheck = Dir$(MyFileName)
If FileCheck = partName1 + MyExtension Then
Set oExcelworkbook = oExcel.Workbooks.Open(MyFileName)
Set oExcelSheet = oExcelworkbook.Worksheets(1)
If oExcel.workbook.worksheets.Open = True Then
oExcel.cells(5, 5) = "PartName"
oExcel.cells(6, 5)=sname
End If
End If
End If
RE: Open excel file and overwrite and check
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Open excel file and overwrite and check
I want to check If open because each sname value returns end of the sub/end sub which means I didnot store sname values and also I did not store snameS' coordinate values and I did not do any calculation.I am thinking that If I save these values on excel file every loop then I can calculate on excel.
For example,
X Y Z
sname- abc.1 10 20 30
dfg.1 50 60 70
sname is sub-partname.
End of the first sub/end sub
I reached abc.1 10 20 30 values before disapear or lost these values I want to save on excel file
Then method reachs dfg.1 50 60 70 values again I check excel is opened else (if not) excel should be activated finally saved dfg.1 values
Sub createSaveFile()
Dim productDocument1 As Document
Set productDocument1 = CATIA.ActiveDocument
'Input box to select txt or xls
exportFormat = InputBox("Please choose format to export the tree as._ Type 'xls' ") 'thats why maybe later it can be changed xls to txt flexible
If exportFormat <> "xls" Then
MsgBox "Did not enter txt or xls. Program cancelled, please retry macro."
Else
'Input box to enter name of file
partName1 = InputBox("Please enter the file name.")
'Input box to enter file location
oLocation = "C:\Macro Files\" & partName1 & "." & exportFormat
productDocument1.ExportData oLocation & partName1 & "." & exportFormat, "txt"
End If
End Sub
Ps. My english can be weak and also I am student so new in catia also script or macro.If I didnt explain clearly,I can try again.
Thank you ferdo.
RE: Open excel file and overwrite and check
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Open excel file and overwrite and check