Consulting

Results 1 to 18 of 18

Thread: Unload command

  1. #1

    Unload command

    Must variables be unloaded before the code ends?

    For instance do these need to be unloaded, and what is the correct syntax?

    Dim i As Integer, pronume(0 To 6) As String, grtot As Integer, starter As Double, finish As Double


    I'm asking because there are many pages and the program blocks after maybe 10 pages, also I am asking because I remember that when I used VB this used to be a common problem.

    Thanks

    PS: Is this program called VBAX, or is that the name of the forum? I mean am I in the wrong place? (I am using VBA)

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    Welcome

    Please take a minute to read the FAQ in the link in my sig


    VBA = Visual Basic for Applications. Similar to VB, but has hooks to work with the MS Office products

    This forum is VBA Express (VBAX for short)

    Normally VBA has pretty good garbage collection/clean up so that when a variable goes out of scope its memory is freed, so they do not need to be explicitly 'unloaded'


    Now, you posted in the PowerPoint forum, but talk about 'pages' so I'm assuming that you are NOT talking about MS Word, but a VERY LONG macro(s) that takes many Page-Downs to go through?

    What do you mean by 'blocks'?? Error message, freezes, crashes, catches fire, ....?


    If you're having issues with a macro, probably a good idea to attach a PPTM file here with the macro and enough data to show the problem
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    I have been working for a year on an English Learning Course written in PowerPoint. It has 196 pages, most of which are interactive (they contain VBA code). I only have the 2007 version of PowerPoint on my old computer. I couldn't download the new PowerPoint because my old computer was Windows XP and it was too old. When I bought a new computer among other things I wanted to see how my program would run on the latest ppt version. Like I said the program stopped running (after a number of pages, actually it was more than 10), it displayed a message and froze. Unfortunately I didn't copy the message and I didn't know that the trial version of ppt was only 5 days long, and now I don't have the message anymore. I ran the whole Course this morning on my old computer; it didn't freeze but after page 130 the sounds on some of the pages stopped working and at the end the pages started to overlap, parts of other pages started to be seen in the current page.
    If there is a list of errors somewhere I might be able to identify what message the new computer displayed.
    I know this is very little to work with but I can't show all the pages of the program here, if somebody could help me anyway that would be great.
    Thanks

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    Pages or Slides?

    Maybe make a copy and delete the last 150 pages/slides and see it that works

    Entirely possible that there's been a PP change since 2007 that is not compatible
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  5. #5
    But as I explained already, there are problems on the 2007 version too.

    I will fix everything on all versions (I will create a version for each version if necessary)

  6. #6
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    Must variables be unloaded before the code ends?

    For instance do these need to be unloaded, and what is the correct syntax?

    Dim i As Integer, pronume(0 To 6) As String, grtot As Integer, starter As Double, finish As Double


    I'm asking because there are many pages and the program blocks after maybe 10 pages, also I am asking because I remember that when I used VB this used to be a common problem.
    Well, VBA is not the same thing a VB, but I guess you could say that they're first cousins

    Large presentations typically don't cause a problem, even with a lot of VBA

    I don't think presentations routinely blocked after maybe 10 pages, even in 2007


    But as I have said already, without having something look at, it's very hard to tell what might be wrong
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  7. #7

    Does this work in the other versions of ppt?

    Quote Originally Posted by Paul_Hossler View Post
    Well, VBA is not the same thing a VB, but I guess you could say that they're first cousins

    Large presentations typically don't cause a problem, even with a lot of VBA

    I don't think presentations routinely blocked after maybe 10 pages, even in 2007


    But as I have said already, without having something look at, it's very hard to tell what might be wrong
    ok...

    Here is the first program from ppt 2007, would it still work in more recent versions?

    (Actually I know it works, but is there any reason why it would slowly block the program)

    The whole project is 70MB is that too much? is that why it starts working poorly after about 100 pages(not 10)?

    Dim i As Integer, Verbe(0 To 14), Trad(0 To 14), finish As Double, starter As Double, grtot As Integer
    
    Sub EmptyText()
    TextBox1.Text = ""
    TextBox2.Text = ""
    TextBox3.Text = ""
    TextBox4.Text = ""
    TextBox5.Text = ""
    TextBox6.Text = ""
    TextBox7.Text = ""
    TextBox8.Text = ""
    TextBox9.Text = ""
    TextBox10.Text = ""
    TextBox11.Text = ""
    TextBox12.Text = ""
    TextBox13.Text = ""
    TextBox14.Text = ""
    TextBox15.Text = ""
    TextBox1.ForeColor = RGB(0, 0, 0)
    TextBox2.ForeColor = RGB(0, 0, 0)
    TextBox3.ForeColor = RGB(0, 0, 0)
    TextBox4.ForeColor = RGB(0, 0, 0)
    TextBox5.ForeColor = RGB(0, 0, 0)
    TextBox6.ForeColor = RGB(0, 0, 0)
    TextBox7.ForeColor = RGB(0, 0, 0)
    TextBox8.ForeColor = RGB(0, 0, 0)
    TextBox9.ForeColor = RGB(0, 0, 0)
    TextBox10.ForeColor = RGB(0, 0, 0)
    TextBox11.ForeColor = RGB(0, 0, 0)
    TextBox12.ForeColor = RGB(0, 0, 0)
    TextBox13.ForeColor = RGB(0, 0, 0)
    TextBox14.ForeColor = RGB(0, 0, 0)
    TextBox15.ForeColor = RGB(0, 0, 0)
    End Sub
    
    Function Word(nr As Integer) As String
    Trad(0) = "BREAD"
    Trad(1) = "EGG"
    Trad(2) = "CHEESE"
    Trad(3) = "WATER"
    Trad(4) = "JUICE"
    Trad(5) = "SPOON"
    Trad(6) = "FORK"
    Trad(7) = "KNIFE"
    Trad(8) = "CUP"
    Trad(9) = "GLASS"
    Trad(10) = "PLATE"
    Trad(11) = "BREAKFAST"
    Trad(12) = "LUNCH"
    Trad(13) = "DINNER"
    Trad(14) = "SNACK"
    Word = Trad(nr)
    End Function
    
    Function Cuvant(nr As Integer) As String
    Verbe(0) = "PAINE"
    Verbe(1) = "OU"
    Verbe(2) = "BRANZA"
    Verbe(3) = "APA"
    Verbe(4) = "SUC"
    Verbe(5) = "LINGURA"
    Verbe(6) = "FURCULITA"
    Verbe(7) = "CUTIT"
    Verbe(8) = "CEASCA"
    Verbe(9) = "PAHAR"
    Verbe(10) = "FARFURIE"
    Verbe(11) = "MIC DEJUN"
    Verbe(12) = "PRANZ"
    Verbe(13) = "CINA"
    Verbe(14) = "GUSTARE"
    Cuvant = Verbe(nr)
    End Function
    
    
    Private Sub CommandButton1_Click()
    CommandButton3.Enabled = False
    If RTrim(LTrim(UCase(TextBox1.Text))) <> Word(0) Then
    TextBox1.Text = Word(0)
    TextBox1.ForeColor = RGB(0, 128, 0)
    grtot = grtot + 1
    End If
    If RTrim(LTrim(UCase(TextBox2.Text))) <> Word(1) Then
    TextBox2.Text = Word(1)
    TextBox2.ForeColor = RGB(0, 128, 0)
    grtot = grtot + 1
    End If
    If RTrim(LTrim(UCase(TextBox3.Text))) <> Word(2) Then
    TextBox3.Text = Word(2)
    TextBox3.ForeColor = RGB(0, 128, 0)
    grtot = grtot + 1
    End If
    If RTrim(LTrim(UCase(TextBox4.Text))) <> Word(3) Then
    TextBox4.Text = Word(3)
    TextBox4.ForeColor = RGB(0, 128, 0)
    grtot = grtot + 1
    End If
    If RTrim(LTrim(UCase(TextBox5.Text))) <> Word(4) Then
    TextBox5.Text = Word(4)
    TextBox5.ForeColor = RGB(0, 128, 0)
    grtot = grtot + 1
    End If
    If RTrim(LTrim(UCase(TextBox6.Text))) <> Word(5) Then
    TextBox6.Text = Word(5)
    TextBox6.ForeColor = RGB(0, 128, 0)
    grtot = grtot + 1
    End If
    If RTrim(LTrim(UCase(TextBox7.Text))) <> Word(6) Then
    TextBox7.Text = Word(6)
    TextBox7.ForeColor = RGB(0, 128, 0)
    grtot = grtot + 1
    End If
    If RTrim(LTrim(UCase(TextBox8.Text))) <> Word(7) Then
    TextBox8.Text = Word(7)
    TextBox8.ForeColor = RGB(0, 128, 0)
    grtot = grtot + 1
    End If
    If RTrim(LTrim(UCase(TextBox9.Text))) <> Word(8) Then
    TextBox9.Text = Word(8)
    TextBox9.ForeColor = RGB(0, 128, 0)
    grtot = grtot + 1
    End If
    If RTrim(LTrim(UCase(TextBox10.Text))) <> Word(9) Then
    TextBox10.Text = Word(9)
    TextBox10.ForeColor = RGB(0, 128, 0)
    grtot = grtot + 1
    End If
    If RTrim(LTrim(UCase(TextBox11.Text))) <> Word(10) Then
    TextBox11.Text = Word(10)
    TextBox11.ForeColor = RGB(0, 128, 0)
    grtot = grtot + 1
    End If
    If RTrim(LTrim(UCase(TextBox12.Text))) <> Word(11) Then
    TextBox12.Text = Word(11)
    TextBox12.ForeColor = RGB(0, 128, 0)
    grtot = grtot + 1
    End If
    If RTrim(LTrim(UCase(TextBox13.Text))) <> Word(12) Then
    TextBox13.Text = Word(12)
    TextBox13.ForeColor = RGB(0, 128, 0)
    grtot = grtot + 1
    End If
    If RTrim(LTrim(UCase(TextBox14.Text))) <> Word(13) Then
    TextBox14.Text = Word(13)
    TextBox14.ForeColor = RGB(0, 128, 0)
    grtot = grtot + 1
    End If
    If RTrim(LTrim(UCase(TextBox15.Text))) <> Word(14) Then
    TextBox15.Text = Word(14)
    TextBox15.ForeColor = RGB(0, 128, 0)
    grtot = grtot + 1
    End If
    finish = Timer
    MsgBox ("Ai terminat in " & Int(finish - starter) & "s si ai avut " & grtot & " greseli.")
    End Sub
    
    Private Sub CommandButton2_Click()
    Call EmptyText
    CommandButton3.Enabled = True
    CommandButton1.Enabled = False
    grtot = 0
    finish = 0
    starter = Timer
    End Sub
    
    Private Sub CommandButton3_Click()
    CommandButton1.Enabled = True
    If RTrim(LTrim(UCase(TextBox1.Text))) <> Word(0) Then
    TextBox1.ForeColor = RGB(256, 0, 0)
    End If
    If RTrim(LTrim(UCase(TextBox2.Text))) <> Word(1) Then
    TextBox2.ForeColor = RGB(256, 0, 0)
    End If
    If RTrim(LTrim(UCase(TextBox3.Text))) <> Word(2) Then
    TextBox3.ForeColor = RGB(256, 0, 0)
    End If
    If RTrim(LTrim(UCase(TextBox4.Text))) <> Word(3) Then
    TextBox4.ForeColor = RGB(256, 0, 0)
    End If
    If RTrim(LTrim(UCase(TextBox5.Text))) <> Word(4) Then
    TextBox5.ForeColor = RGB(256, 0, 0)
    End If
    If RTrim(LTrim(UCase(TextBox6.Text))) <> Word(5) Then
    TextBox6.ForeColor = RGB(256, 0, 0)
    End If
    If RTrim(LTrim(UCase(TextBox7.Text))) <> Word(6) Then
    TextBox7.ForeColor = RGB(256, 0, 0)
    End If
    If RTrim(LTrim(UCase(TextBox8.Text))) <> Word(7) Then
    TextBox8.ForeColor = RGB(256, 0, 0)
    End If
    If RTrim(LTrim(UCase(TextBox9.Text))) <> Word(8) Then
    TextBox9.ForeColor = RGB(256, 0, 0)
    End If
    If RTrim(LTrim(UCase(TextBox10.Text))) <> Word(9) Then
    TextBox10.ForeColor = RGB(256, 0, 0)
    End If
    If RTrim(LTrim(UCase(TextBox11.Text))) <> Word(10) Then
    TextBox11.ForeColor = RGB(256, 0, 0)
    End If
    If RTrim(LTrim(UCase(TextBox12.Text))) <> Word(11) Then
    TextBox12.ForeColor = RGB(256, 0, 0)
    End If
    If RTrim(LTrim(UCase(TextBox13.Text))) <> Word(12) Then
    TextBox13.ForeColor = RGB(256, 0, 0)
    End If
    If RTrim(LTrim(UCase(TextBox14.Text))) <> Word(13) Then
    TextBox14.ForeColor = RGB(256, 0, 0)
    End If
    If RTrim(LTrim(UCase(TextBox15.Text))) <> Word(14) Then
    TextBox15.ForeColor = RGB(256, 0, 0)
    End If
    End Sub
    Last edited by Aussiebear; 08-04-2022 at 08:02 AM. Reason: Added code tags to supplied code

  8. #8
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    I doubt that anyone will try to re-create your presentation

    It'd be much easier to investigate if you would attach a presentation with 4-5 slides and the userforms and the macros, along with any directions that are neede
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  9. #9
    I discovered that I still have access to ppt (read-only) even if the trial period ended.

    The following command doesn't work in the latest version:

    face2.Visible = False

    can i replace it with something else? (face2 is a label)

  10. #10
    Moderator VBAX Guru Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    4,997
    Location
    @ Emphasis. As Paul has been quite rightly pointing out, you are making it very difficult for us to assist you with the snippets of code you have presented. I also note your reluctance to provide as requested a small section of your program, so any assistance is simply based on a guess as to what your intent was in designing the code/presentation.

    So far you have slowly admitted that:
    1. You constructed the powerpoint presentation some time ago, to promote learning of the English language.
    2. You have updated your old XP system computer with something newer, but we still don't know what system is running, which version of Office you have ( apart from you may be running a "trial version" of Powerpoint. This information is very helpful to those wanting to assist you.
    3. From a brief perusal of the very small section of code so far presented, one may assume that your coding skills are limited. For example in Post #7 you Dim some statements but not all, you have command buttons labels as CommandButton1, CommandButton3, where as good coding will have the cmdButton called something relevant. For others trying to understand your code this makes things more difficult. You asked early on in Post #1 about variables being unloaded.... the reality is that VBA will attempt to unload them if it believes they no longer have scope. Are they meant to be Public or Private? What length of time are they needed for?
    4. What we need from you is the following;
    a) A brief description of what the powerpoint presentation is meant to be doing,
    b) The type of system you are running, including version of Office,
    c) A sample of your presentation, so we can understand what it is that you are attempting to do,
    d) Snippets of code such as "face2.Visible = False" need to be shown with its accompanying section of code. Earlier I indicated that your coding skills are limited and here's another example of your code not being accurate. "face2.Visible = False" , other than you, no one would know its a Label until you told us.
    e) May I suggest you put the statement "Option Explicit" as your opening line for sections of code. You'd be surprised at the number of "errors" it finds in code. Correcting these will assist you immensely. You will find the odd person suggesting that you don't need to do this but for new to VBA or limited skilled VBA coders it actually good housekeeping.

    How big is your Powerpoint presentation file?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  11. #11
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    Code like this is extremely inefficient; why are you setting Trad(..) every time you call Word() ?

    Dim Trad(0 To 14)
    
    Function Word(nr As Integer) As String
    Trad(0) = "BREAD"
    Trad(1) = "EGG"
    Trad(2) = "CHEESE"
    Trad(3) = "WATER"
    Trad(4) = "JUICE"
    Trad(5) = "SPOON"
    Trad(6) = "FORK"
    Trad(7) = "KNIFE"
    Trad(8) = "CUP"
    Trad(9) = "GLASS"
    Trad(10) = "PLATE"
    Trad(11) = "BREAKFAST"
    Trad(12) = "LUNCH"
    Trad(13) = "DINNER"
    Trad(14) = "SNACK"
    Word = Trad(nr) 
    End Function
    You could

    1. Make Trad ( ) a Public variable and initialize Trad in a setup sub. Don't even need a function like Word, just reference i.e. Trad(nr)
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  12. #12
    I created a demo made up of 11 slides
    I created a github project called powerpoint.
    Username: Dumeetra
    It doesn't contain userforms, only powerpoint slides.
    The project is created in WinXP in ppt2007, as I already said.

    I only have the 2007 version of PowerPoint on my old computer. I couldn't download the new PowerPoint because my old computer was Windows XP and it was too old.


    Now, could somebody please tell me if the project works in newer OS's and in newer versions of powerpoint?
    Thank you

  13. #13
    Moderator VBAX Guru Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    4,997
    Location
    @Emphasis. You can attach the demo file here by using Go Advanced/ Manage attachments/ Choose file/ Upload
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  14. #14
    I tried to upload, but it said that 1M is the limit.
    Each slide is over 1 M.
    I tried compressing but it wasn't enough.

  15. #15
    Moderator VBAX Guru Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    4,997
    Location
    On one hand you say the program is only 70mb comprising of over 130 pages, but in your last post you suggest that each slide is over 1mb. I'm somewhat surprised your old system would even run the presentation. Its a big ask for others to upload your presentation if its that big.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  16. #16
    Quote Originally Posted by Aussiebear View Post
    On one hand you say the program is only 70mb comprising of over 130 pages, but in your last post you suggest that each slide is over 1mb. I'm somewhat surprised your old system would even run the presentation. Its a big ask for others to upload your presentation if its that big.

    The pptm is 8M.
    Being a language learning software it has audio files as well. The audio is 70M
    The audio is comprised of one thousand short mp3files. If I can use a different format please let me know.
    The audio is external, it is not embedded into the pptm. I think that helps it load faster, doesn't it?
    But that also means that the audio files need to be placed exactly in the same place on any computer, doesn't it?

    I did not update WinXP with anything.
    Last edited by Emphasis; 08-14-2022 at 01:55 AM.

  17. #17
    Moderator VBAX Guru Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    4,997
    Location
    You can definitely strip out the audio files. What does that bring the file size down to?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  18. #18
    8M. The demo on github is 2M

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •