Forum

Free Download More Info
Welcome to the Personal Stock Streamer Developers Forum. Anyone can read messages, but you must be a registered user in order to post. (Sorry, we did this in order to prevent forum spam.)

Everyone who is registered for the Developers Forum on this site should now also have permission to log in and post to the Support Forum.  This was done by hand, so we may have missed a couple of people.  Please let us know if you do not have access to both forums.
Subscribe to RSS Feed
PSS Developers Forum -> Checking for and removing a portfolio
Not logged in.
2006-05-31 17:47:01
1 of 8
#752
I used the sample code you provided to navigate through the portfolios and made a modification to find the portfolio and remove it, but there is something wrong with the way I am trying to use Remove().

Here are the attempts I have made:
document.Remove(portfolio)
document.Remove("test")
portfolios.Remove(portfolio)
portfolios.Remove("test")
Remove(portfolio)
Remove("test")

Here is my code snippet:

' get the active document
Dim document
set document = application.ActiveDocument

' get the portfolios collection
Dim portfolios
set portfolios = document.Portfolios

Dim portfolio

' show something about each portfolio
   for each portfolio in portfolios
      if portfolio.Name = "test" then
         portfolios.Remove(portfolio)
      end if
               
   next

...

Larry E. Hayes
Investors Haven

Larry E. Hayes
Investors Haven
Posted by: lehayes
2006-05-31 18:27:45
2 of 8
#753
in reply to #752
Also, if I have tickers and folders in this portfolio, will I have to clear them out before I can delete the portfolio? This currently is not the case, but I thought I might ask while I am already bothering you.
      
Larry E. Hayes
Investors Haven

Larry E. Hayes
Investors Haven
Posted by: lehayes
2006-05-31 18:47:46
3 of 8
#754
in reply to #753
Ok, one more request here. Can you show me a snippet of adding and removing folders within a Portfolio?
      
Larry E. Hayes
Investors Haven

Larry E. Hayes
Investors Haven
Posted by: lehayes
2006-05-31 23:46:47
4 of 8
#755
in reply to #754
Last one for now... can you show me a code snippet for creating a menu item that consists of child menu items?

Tools
   |
   |
   MyMenu
      |
      |
      Child1
      Child2
      Child3
      
Larry E. Hayes
Investors Haven

Larry E. Hayes
Investors Haven
Posted by: lehayes
2006-06-01 01:31:33
5 of 8
#756
in reply to #752
What error message are you getting? This isn't a problem in how you're using Remove(), but which object you're trying to use Remove() on, because the document.Portfolios collection doesn't have a Remove() method. There is currently no document.RemovePortfolio() method that goes along with the document.InsertPortfolio() method, because we didn't believe that you should be able to programmatically remove entire portfolios. We may reconsider this position in a future release, but right now you can only remove individual folders within a portfolio.
      
Anatoly Ivasyuk
DTLink Software

Anatoly Ivasyuk
DTLink Software
2006-06-01 01:32:24
6 of 8
#757
in reply to #753
No, you do not have to clear out a folder before you remove it. All contained tickers and transactions will be removed with it.
      
Anatoly Ivasyuk
DTLink Software

Anatoly Ivasyuk
DTLink Software
2006-06-01 01:36:40
7 of 8
#758
in reply to #754
To add a folder, create a new folder object using Document::CreateFolder, set its properties, and insert it into the target folder using the Folder::Insert method. The exact syntax for these is in the object model documentation. To delete a folder or ticker from within another folder or portfolio, use the Folder::Remove method as you have been trying to do. (As I mentioned, it is not currently possible to remove a top-level portfolio from a document.)
      
Anatoly Ivasyuk
DTLink Software

Anatoly Ivasyuk
DTLink Software
2006-06-01 01:39:31
8 of 8
#759
in reply to #755
There is already sample code for inserting a menu under the Tools item. To insert a sub-menu (pop-up menu), use

Set submenu = menu.InsertMenu(index, name)

Then insert your items into the sub-menu with

submenu.InsertItem(index, name)
      
Anatoly Ivasyuk
DTLink Software

Anatoly Ivasyuk
DTLink Software