Excel VBA Userform crash by various Images beeing uploaded












0















I am working on a programme where the user clicks a button on the main worksheet and a Userform will be opened. That Userform basically consists of a Imageframe and another button. By Clicking the Button the Imageframe changes its background color after every 0.2 Seconds. It looks like a little color video. After about 10 seconds the 'video' should stop and a selected picture should be uploaded to the frame.



I have the great problem, that my userform crashes after a certain amount of time during the 'video' is showed. It is frustrating and i cannot understand the problem, because it randomly crashes sometimes after 5 seconds, another time after 8 seconds etc. After the crash the worksheet is showed and the userform is hidden behind.



My question is if someone knows how i prevent the userform to crash OR if after there is a command to bring the userform up to the first layer automatically.



this is my code for the button-click:



    For i = 1 To 15     'loop for showtime color sequenz
Randomize
DisplayUserform.NameBox.Caption = MainSheet.Cells(Int(nrempl * Rnd + 1), 11)
Randomize
DisplayUserform.DisplayImage.BackColor = RGB(Int(255 * Rnd + 1), Int(255 * Rnd + 1), Int(255 * Rnd + 1))
DisplayUserform.Repaint
stoptime = stoptime + 30
Sleep stoptime
Next

DisplayUserform.DisplayImage.Picture = LoadPicture("C:Usersuib25432PicturesMitarbeiter" & guilty & ".jpg")
DisplayUserform.NameBox.Caption = guilty









share|improve this question




















  • 2





    What -precisely- does "crashes" mean? Do you get a run-time error? If so, which?

    – jkpieterse
    Nov 23 '18 at 11:11











  • crashes in this case means that I get a 'no respond' message, and directly after that the userform shuts down. I have to click the excel-icon again on my taskbar to reactivate the userform.

    – J.schmidt
    Nov 23 '18 at 12:19











  • I don't see how clicking the Excel icon would bring back the userform if it was closed.

    – jkpieterse
    Nov 23 '18 at 16:18
















0















I am working on a programme where the user clicks a button on the main worksheet and a Userform will be opened. That Userform basically consists of a Imageframe and another button. By Clicking the Button the Imageframe changes its background color after every 0.2 Seconds. It looks like a little color video. After about 10 seconds the 'video' should stop and a selected picture should be uploaded to the frame.



I have the great problem, that my userform crashes after a certain amount of time during the 'video' is showed. It is frustrating and i cannot understand the problem, because it randomly crashes sometimes after 5 seconds, another time after 8 seconds etc. After the crash the worksheet is showed and the userform is hidden behind.



My question is if someone knows how i prevent the userform to crash OR if after there is a command to bring the userform up to the first layer automatically.



this is my code for the button-click:



    For i = 1 To 15     'loop for showtime color sequenz
Randomize
DisplayUserform.NameBox.Caption = MainSheet.Cells(Int(nrempl * Rnd + 1), 11)
Randomize
DisplayUserform.DisplayImage.BackColor = RGB(Int(255 * Rnd + 1), Int(255 * Rnd + 1), Int(255 * Rnd + 1))
DisplayUserform.Repaint
stoptime = stoptime + 30
Sleep stoptime
Next

DisplayUserform.DisplayImage.Picture = LoadPicture("C:Usersuib25432PicturesMitarbeiter" & guilty & ".jpg")
DisplayUserform.NameBox.Caption = guilty









share|improve this question




















  • 2





    What -precisely- does "crashes" mean? Do you get a run-time error? If so, which?

    – jkpieterse
    Nov 23 '18 at 11:11











  • crashes in this case means that I get a 'no respond' message, and directly after that the userform shuts down. I have to click the excel-icon again on my taskbar to reactivate the userform.

    – J.schmidt
    Nov 23 '18 at 12:19











  • I don't see how clicking the Excel icon would bring back the userform if it was closed.

    – jkpieterse
    Nov 23 '18 at 16:18














0












0








0








I am working on a programme where the user clicks a button on the main worksheet and a Userform will be opened. That Userform basically consists of a Imageframe and another button. By Clicking the Button the Imageframe changes its background color after every 0.2 Seconds. It looks like a little color video. After about 10 seconds the 'video' should stop and a selected picture should be uploaded to the frame.



I have the great problem, that my userform crashes after a certain amount of time during the 'video' is showed. It is frustrating and i cannot understand the problem, because it randomly crashes sometimes after 5 seconds, another time after 8 seconds etc. After the crash the worksheet is showed and the userform is hidden behind.



My question is if someone knows how i prevent the userform to crash OR if after there is a command to bring the userform up to the first layer automatically.



this is my code for the button-click:



    For i = 1 To 15     'loop for showtime color sequenz
Randomize
DisplayUserform.NameBox.Caption = MainSheet.Cells(Int(nrempl * Rnd + 1), 11)
Randomize
DisplayUserform.DisplayImage.BackColor = RGB(Int(255 * Rnd + 1), Int(255 * Rnd + 1), Int(255 * Rnd + 1))
DisplayUserform.Repaint
stoptime = stoptime + 30
Sleep stoptime
Next

DisplayUserform.DisplayImage.Picture = LoadPicture("C:Usersuib25432PicturesMitarbeiter" & guilty & ".jpg")
DisplayUserform.NameBox.Caption = guilty









share|improve this question
















I am working on a programme where the user clicks a button on the main worksheet and a Userform will be opened. That Userform basically consists of a Imageframe and another button. By Clicking the Button the Imageframe changes its background color after every 0.2 Seconds. It looks like a little color video. After about 10 seconds the 'video' should stop and a selected picture should be uploaded to the frame.



I have the great problem, that my userform crashes after a certain amount of time during the 'video' is showed. It is frustrating and i cannot understand the problem, because it randomly crashes sometimes after 5 seconds, another time after 8 seconds etc. After the crash the worksheet is showed and the userform is hidden behind.



My question is if someone knows how i prevent the userform to crash OR if after there is a command to bring the userform up to the first layer automatically.



this is my code for the button-click:



    For i = 1 To 15     'loop for showtime color sequenz
Randomize
DisplayUserform.NameBox.Caption = MainSheet.Cells(Int(nrempl * Rnd + 1), 11)
Randomize
DisplayUserform.DisplayImage.BackColor = RGB(Int(255 * Rnd + 1), Int(255 * Rnd + 1), Int(255 * Rnd + 1))
DisplayUserform.Repaint
stoptime = stoptime + 30
Sleep stoptime
Next

DisplayUserform.DisplayImage.Picture = LoadPicture("C:Usersuib25432PicturesMitarbeiter" & guilty & ".jpg")
DisplayUserform.NameBox.Caption = guilty






excel vba






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 17 '18 at 10:11









Darren Bartrup-Cook

14k11533




14k11533










asked Nov 23 '18 at 11:04









J.schmidtJ.schmidt

663120




663120








  • 2





    What -precisely- does "crashes" mean? Do you get a run-time error? If so, which?

    – jkpieterse
    Nov 23 '18 at 11:11











  • crashes in this case means that I get a 'no respond' message, and directly after that the userform shuts down. I have to click the excel-icon again on my taskbar to reactivate the userform.

    – J.schmidt
    Nov 23 '18 at 12:19











  • I don't see how clicking the Excel icon would bring back the userform if it was closed.

    – jkpieterse
    Nov 23 '18 at 16:18














  • 2





    What -precisely- does "crashes" mean? Do you get a run-time error? If so, which?

    – jkpieterse
    Nov 23 '18 at 11:11











  • crashes in this case means that I get a 'no respond' message, and directly after that the userform shuts down. I have to click the excel-icon again on my taskbar to reactivate the userform.

    – J.schmidt
    Nov 23 '18 at 12:19











  • I don't see how clicking the Excel icon would bring back the userform if it was closed.

    – jkpieterse
    Nov 23 '18 at 16:18








2




2





What -precisely- does "crashes" mean? Do you get a run-time error? If so, which?

– jkpieterse
Nov 23 '18 at 11:11





What -precisely- does "crashes" mean? Do you get a run-time error? If so, which?

– jkpieterse
Nov 23 '18 at 11:11













crashes in this case means that I get a 'no respond' message, and directly after that the userform shuts down. I have to click the excel-icon again on my taskbar to reactivate the userform.

– J.schmidt
Nov 23 '18 at 12:19





crashes in this case means that I get a 'no respond' message, and directly after that the userform shuts down. I have to click the excel-icon again on my taskbar to reactivate the userform.

– J.schmidt
Nov 23 '18 at 12:19













I don't see how clicking the Excel icon would bring back the userform if it was closed.

– jkpieterse
Nov 23 '18 at 16:18





I don't see how clicking the Excel icon would bring back the userform if it was closed.

– jkpieterse
Nov 23 '18 at 16:18












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53445493%2fexcel-vba-userform-crash-by-various-images-beeing-uploaded%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53445493%2fexcel-vba-userform-crash-by-various-images-beeing-uploaded%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Hercules Kyvelos

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud