Sign in to follow this  
Followers 0
Guest Rich101

excel macro to cicode

4 posts in this topic

I would like to have a button on a graphics screen when pushed do the following in cicode or vba or whatever is best using Citect. When pushed: search for a excel file called master. retrieve and paste part of four different event logs onto 1st sheet. save information to another worksheet labeled (day1)by using date on master sheet. Example 03/01/2004 to day1, 03/02/04 to day2, worksheets. When completed, exit out of all four retrieved worksheets. Exit out of master workseet. Back to original screen with pushbutton. Below is an excel macro that does this up to the point of retrieving and saving on the 3rd worksheet. I actually what it saved as described above. Sub Macro1() ' ' Macro1 Macro ' Macro recorded 3/1/04 by Connie ' ' Keyboard Shortcut: Ctrl+z ' ChDir "C:\My Documents\excel test" Workbooks.Open FileName:="C:\My Documents\excel test\Book1.xls" Range("A19").Select Selection.Copy With ActiveWindow .Top = 116.5 .Left = 118.75 End With Windows("master.xls").Activate Range("A1").Select ActiveSheet.Paste Range("A4").Select Workbooks.Open FileName:="C:\My Documents\excel test\Book2.xls" Range("B1:E11").Select Application.CutCopyMode = False Selection.Copy With ActiveWindow .Top = 76 .Left = 109 End With Windows("master.xls").Activate Range("E1").Select ActiveSheet.Paste Range("E4").Select Sheets("Sheet2").Select Range("A1:H11").Select Application.CutCopyMode = False Selection.Copy Sheets("Sheet3").Select Range("A1").Select Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False Range("A10").Select Sheets("master").Select Cells.Select Application.CutCopyMode = False Selection.ClearContents Range("A7").Select Windows("Book2.xls").Activate With ActiveWindow .Top = 70 .Left = -20 End With ActiveWindow.Close Windows("Book1.xls").Activate With ActiveWindow .Top = 104.5 .Left = -0.5 End With ActiveWindow.Close Range("B2").Select End Sub

Share this post


Link to post
Share on other sites
So you have the macro working, you just want to launch it with a button? See attached file. Also, if you want to add this yourself, click on VIEW, turn on the FORMS menu. Draw a button, then it will ask you if you want to assign it to a macro. test.xls

Share this post


Link to post
Share on other sites
where I want to launch it from is a citect graphics screen, then close excel and return to the citect graphics screen. Or any oher way from citect that will work. I wonder if ther is a way for a user to put type in a date (02/21/2004 or 01/14/2004) for example and the correct saved combined form saved on file prints out? That would be great. Rich.

Share this post


Link to post
Share on other sites
I dunno anything about citect, but I can help with Excel. You can use the now() function to get the current time and date. I used the now() and extracted the time and date information I needed to save the file name as today's date in my Excel Logger program. Check out this download http://forums.mrplc.com/index.php?&act=Down...&CODE=02&id=134 In there you can see how I saved the excel file as today's dates. As far as citect, I never used it yet.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0