Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Open excel file and overwrite and check

Open excel file and overwrite and check

Open excel file and overwrite and check

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

RE: Open excel file and overwrite and check

I try to open and overwrite and also check if it is opened.I mean these 3 step like in below but I am not succesfull.(maybe this is more clear now)

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

First of all in below I created xls files(thanks E.Ross) and save defined path. And also I want to access this file then I want to check "if xls opened or activated" else if not I want to open and I want to overwrite these values "oExcel.cells(6, 5)=sname" sname(1),sname(2)....

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,
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."
'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

Yes,exactly you are right.in meanwhile I got CAT Portable Script but I didnot examine deeply. I will look this folder again.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close