• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 140
  • Last Modified:

Excel ComboBox list contents not saving

I made a VB application which is using a lot of ComboBox that are populated from a database. It's like a big dynamic form that is going to be built on a server and distributed then to the clients. The problem is that the program is working quite alright, but when it comes to save, close, quit the document, everything is saving exept the ComboBoxes lists contents. Here is the function I used even if I don't think there is any error in it :

Private Function Destructor()
    xlwkbk.Worksheets.Item(1).Range("A1").Select
    xlwkbk.SaveAs ("C:\Test.xls")
    xlwkbk.Close
    adoConn.Close
    xlobj.Application.DisplayAlerts = True
    xlobj.Application.ScreenUpdating = True
    xlobj.Application.Visible = True
    xlobj.Quit
    If Not (adoConn Is Nothing) Then Set adoConn = Nothing
    If Not (xlSheet Is Nothing) Then Set xlSheet = Nothing
    If Not (xlwkbk Is Nothing) Then Set xlwkbk = Nothing
    If Not (xlobj Is Nothing) Then Set xlobj = Nothing
End Function

THNKS  !
0
Wiz_of_oz_777
Asked:
Wiz_of_oz_777
  • 3
  • 3
1 Solution
 
Richie_SimonettiIT OperationsCommented:
AFAIK, you cannot do that!
Comboboxes always are populated at run time here, except that you save the contents of it in a range of worksheet and link that range to the combobox.
0
 
Wiz_of_oz_777Author Commented:
Richie Simonetti :
AFAIK, you cannot do that!
Comboboxes always are populated at run time here, except that you save the contents of it in a range of worksheet and link that range to the combobox.

Actually that is wrong. You are right that it wasn't featured in early versions of office (95 & 97) but It is working in Excel 2000 & XP. Since those versions are retro-compatible, it is possible to save the list itself with the rest of the file and to reopen it with 97 as long as it was created with 2000 & up excel versions.


0
 
Richie_SimonettiIT OperationsCommented:
How do you populate the combo in first place?
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Richie_SimonettiIT OperationsCommented:
or better to say, how do populate them the first time?
0
 
Wiz_of_oz_777Author Commented:
Here's the code I used to populate every combobox:
         lrs_adoRS.Open as_SQL, adoConn, adOpenDynamic, adLockReadOnly
    lrs_adoRS.MoveFirst
    Do While Not (lrs_adoRS.EOF)
        i = i + 1
        ActiveSheet.OLEObjects(as_NomObjet).Object.AddItem _
        (lrs_adoRS.Fields(as_Field).Value)
        lrs_adoRS.MoveNext
    Loop
    lrs_adoRS.Close
0
 
Wiz_of_oz_777Author Commented:
I also used a simple copy & paste command to populate comboboxes that could be copied, to optimise the run time. But every combobox before I close, are correctly populated and visible... Just I didn't noticed Excel 95/97 could'nt save the lists populated from databases... after tests only XP (which is the only other I've tried) does.
0
 
SpideyModCommented:
PAQ'd and all 50 points refunded.

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now