ATTENTION

This FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices.


flexsim.com

Go Back   FlexSim Community Forum > FlexSim Software > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 11-06-2008
david_white david_white is offline
Flexsim User
 
Join Date: Jun 2008
Posts: 18
Downloads: 1
Uploads: 1
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 145
david_white is on a distinguished road
Default Exporting Global Tables with Excel 2007

I used to be able to export my global tables using the Custom Export commands like:

excelopen(filename); // open a link with an Excel workbook
excelsetsheet("MyTab"); // set the active worksheet - sheet names should
excelexporttable("MyTable",1,1,numRows,1 );

But I've recently upgraded my Microsoft Office suite and now have Excel 2007.....and now I can't export. Is there a patch or upgrade for my FlexSim that will allow it to export using the new Excel?
Thanks,
David White

Last edited by Brandon Peterson; 11-06-2008 at 11:05 AM. Reason: removed email address
  #2  
Old 11-06-2008
Brandon Peterson's Avatar
Brandon Peterson Brandon Peterson is offline
The Flexsim Consultant
 
Join Date: Jul 2007
Location: Salt Lake City, Utah
Posts: 382
Downloads: 29
Uploads: 6
Thanks: 192
Thanked 516 Times in 235 Posts
Rep Power: 490
Brandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant future
Default

David,

I hope you don't mind I removed your email address from your post. I did this so that it wouldn't be picked up if someone's program searches our website for email addresses to add to a spam list. If you want to put it back up you can and I won't take it down again (Use the edit button to edit your post), but I figured better safe than sorry.

As for you question I don't know why this would happen but I'm sure someone on the forum will.

Good luck with your question,
Brandon
__________________
thats not normal.
  #3  
Old 11-06-2008
AJ Bobo's Avatar
AJ Bobo AJ Bobo is offline
Flexsim Senior Developer
 
Join Date: Jul 2007
Posts: 108
Downloads: 8
Uploads: 0
Thanks: 23
Thanked 89 Times in 41 Posts
Rep Power: 221
AJ Bobo is a jewel in the roughAJ Bobo is a jewel in the roughAJ Bobo is a jewel in the roughAJ Bobo is a jewel in the rough
Default

David,

I'm using Excel 2007 and the excelexporttable() command is working for me. Are you calling excelclose() when you are done? If so, are you passing any parameters to it? Remember that excelclose(0) will close the workbook without saving any changes and excelclose(1) will save your changes before writing to it.

A.J.
  #4  
Old 11-07-2008
david_white david_white is offline
Flexsim User
 
Join Date: Jun 2008
Posts: 18
Downloads: 1
Uploads: 1
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 145
david_white is on a distinguished road
Default

Thanks Brandon and AJ. I didn't change anything but now it's working???? I did reboot during that time, so maybe my computer was just fried and I didn't know it. Thanks for your responses though.
  #5  
Old 11-07-2008
jlaird jlaird is offline
Flexsim User
 
Join Date: Jul 2008
Posts: 5
Downloads: 0
Uploads: 0
Thanks: 0
Thanked 1 Time in 1 Post
Rep Power: 0
jlaird is on a distinguished road
Default Unqualified Method Calls?

http://support.microsoft.com/default...;en-us;Q319832

When trying to run the custom ExcelExport code mentioned above multiple times, I receive the following error:

"The object invoked has disconnected from its clients."

I have not been able to spend a large amount of time on this problem, but I noticed the article above states that is a known issue.

I did not find any posts of other FlexSim users encountering this problem so I was curious if there is a solution or perhaps I'm not using the ExcelExport correctly the second+ times?

Thanks!
Jonathan Laird
  #6  
Old 11-10-2008
AJ Bobo's Avatar
AJ Bobo AJ Bobo is offline
Flexsim Senior Developer
 
Join Date: Jul 2007
Posts: 108
Downloads: 8
Uploads: 0
Thanks: 23
Thanked 89 Times in 41 Posts
Rep Power: 221
AJ Bobo is a jewel in the roughAJ Bobo is a jewel in the roughAJ Bobo is a jewel in the roughAJ Bobo is a jewel in the rough
Default

Jonathan,

This isn't an error that I've ever seen. It may be something in your code. Flexsim's Excel communication system can be pretty picky about how it expects you to make certain function calls. If you're missing something or doing something in the wrong order strange things can happen. I wonder if this is one of those times. Can you share a simplified version of your code or model with us so we can see what's happening? Thanks.

A.J.
  #7  
Old 11-10-2008
jlaird jlaird is offline
Flexsim User
 
Join Date: Jul 2008
Posts: 5
Downloads: 0
Uploads: 0
Thanks: 0
Thanked 1 Time in 1 Post
Rep Power: 0
jlaird is on a distinguished road
Default Code to Produce OLE Error

A.J.,

It might be the code. I'll post the code below with steps to reproduce the error. Thanks for looking into the issue.

Warning: This will most likely produce OLE exception pop-ups in FlexSim and prevent FlexSim from closing (requiring Task Manager to end it).

Assumption: 'filename' contains a path to an excel file
Description: 'numRows' will get the count of how many data entries there are in another table (#2). Method 'excelexporttable' will then export 'numRows' quantity from table (#2).
________________________
excelopen(filename); // open a link with an Excel workbook
int numRows;
numRows = gettablenum("TatCounts",1,1) ;
excelcreatesheet("TatStatToAdapterUnload");
excelsetsheet("TatStatToAdapterUnload");
excelexporttable("TatStatToAdapterUnload",1,1,numR ows,1 );
________________________

1. Create an empty workbook excel file named 'TestExport.xls'.
2. Place the code above into the 'Custom Export' Excel GUI button code, changing the names of the Global Table references if need be.
3. Make a Global Table with numeric data only in column 1 (20-50 values at least). Note: Remove 'numRows' and simply use hard-coded value such as 20-50.
4. Save your work in FlexSim.
5. Click the 'Custom Export' button to export data to Excel.
6. Select the open 'TestExport.xls' file and all data should be exported correctly.
7. Clicking the 'Custom Export' button again should be okay. However, if you were to close the Excel file 'TestExport.xls' the issue occurs...
8. After closing the Excel file, click 'Custom Export' again.
9. The OLE pop-up errors should appear. Must end-task FlexSim and restart to make export excel work again.

Question - Is it mandatory to close the excel workbook at the end of the code block? //excelclose()

Thanks,
Jonathan
  #8  
Old 11-10-2008
AJ Bobo's Avatar
AJ Bobo AJ Bobo is offline
Flexsim Senior Developer
 
Join Date: Jul 2007
Posts: 108
Downloads: 8
Uploads: 0
Thanks: 23
Thanked 89 Times in 41 Posts
Rep Power: 221
AJ Bobo is a jewel in the roughAJ Bobo is a jewel in the roughAJ Bobo is a jewel in the roughAJ Bobo is a jewel in the rough
Default

Jonathan,

Yes. You have to call excelclose(). There are two sets of commands that work in pairs when you are communicating between Flexsim and Excel. If you call excelopen() then you MUST call excelclose(). If you call excellaunch() you must call excelquit(). The open/close pair is always used when communicating with Excel. The launch/quit pair isn't used much anymore. It used to be mandatory, but now it just slows things down so I don't recommend using it.

Roughly, what happens in the Excel communication system is that Flexsim establishes a connection to the workbook and Excel when excelopen() is called. If you close that connection by closing the workbook yourself, it will confuse Flexsim and later calls to the Excel commands may not work. If that connection is still active when you try to close Flexsim, Flexsim will wait until it is gone to close. That's why you've had to use the Task Manager to close Flexsim.

Note that you can use excelsave() or excelclose(1) to save the changes to the file before it is closed.

A.J.
  #9  
Old 11-11-2008
jlaird jlaird is offline
Flexsim User
 
Join Date: Jul 2008
Posts: 5
Downloads: 0
Uploads: 0
Thanks: 0
Thanked 1 Time in 1 Post
Rep Power: 0
jlaird is on a distinguished road
Default Thanks A.J.

A.J.,

I figured it had to be something like that as I was completing my post... and thought I'd ask the basic question.

Going back and rereading the command documentation it does say to call excelclose(). Well, sorry to waste your time. Thought I read the command description, but I probably only breezed over it.

Jonathan Laird


Thread Thread Starter Forum Replies Last Post
help! order picking process with global tables Charmaine Ng Q&A 3 11-06-2008 11:24 AM
Limit in the completion hints? Global Tables, Global Variables, etc.? Tom David Gripes and Goodies 6 09-09-2008 04:05 PM
Automatically generated global tables Sebastian Dransfeld Gripes and Goodies 1 09-01-2008 12:44 PM
Automated runs / Exporting mdb file.. Nico Zahn Q&A 14 12-17-2007 11:26 AM
Excel and global tables Bill Nordgren Q&A 2 10-15-2007 04:36 AM


All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.