Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Progress bar question

Posted on 2006-11-10
4
Medium Priority
?
223 Views
Last Modified: 2010-04-30
Hi,

I have this code:

        FileCopy SystemDir & "\Template.xls", cdlg.filename
       
        Set xlApp = CreateObject("Excel.Application")
        Set mysheet = xlApp.Workbooks.Open(cdlg.filename).Sheets(1)
           
        mysheet.Cells(4, 1).Value = Trim(Me.StoreName.Text)
        mysheet.Cells(4, 2).Value = Trim(Me.StoreNumber.Text)
        mysheet.Cells(4, 3).Value = Trim(Me.StoreHours.Text)
        mysheet.Cells(4, 4).Value = Trim(Me.SetPoint.Text)
        mysheet.Cells(4, 5).Value = Trim(Me.Days.Text)
        mysheet.Cells(4, 6).Value = Trim(Me.Employee.Text)
        mysheet.Cells(4, 7).Value = Trim(Me.preOpen.Text)
        mysheet.Cells(4, 8).Value = Trim(Me.Open.Text)
        mysheet.Cells(4, 9).Value = Trim(Me.preClose.Text)
        mysheet.Cells(4, 10).Value = Trim(Me.Unoccupied.Text)
        mysheet.Cells(4, 11).Value = Trim(Me.StoreContact.Text)
        mysheet.Cells(4, 12).Value = Trim(Me.Address.Text)
       
        j = 0
       
        For i = 1 To 12
            If (IsNull(Trim(Me.Controls("DateStart" & i).Text)) Or Trim(Me.Controls("DateStart" & i).Text) = "" Or Trim(Me.Controls("DateStart" & i).Text) = "__/__/____") And _
               (IsNull(Trim(Me.Controls("DateEnd" & i).Text)) Or Trim(Me.Controls("DateEnd" & i).Text) = "" Or Trim(Me.Controls("DateEnd" & i).Text) = "__/__/____") And _
               (IsNull(Trim(Me.Controls("StoreOpen" & i).Text)) Or Trim(Me.Controls("StoreOpen" & i).Text) = "" Or Trim(Me.Controls("StoreOpen" & i).Text) = "__:__ __") And _
               (IsNull(Trim(Me.Controls("StoreClosed" & i).Text)) Or Trim(Me.Controls("StoreClosed" & i).Text) = "" Or Trim(Me.Controls("StoreClosed" & i).Text) = "__:__ __") Then
                j = j + 1
            Else
                mysheet.Cells(i + 3 - j, 13).Value = Trim(Me.Controls("DateStart" & i).Text)
                mysheet.Cells(i + 3 - j, 14).Value = Trim(Me.Controls("DateEnd" & i).Text)
                mysheet.Cells(i + 3 - j, 15).Value = Trim(Me.Controls("StoreOpen" & i).Text)
                mysheet.Cells(i + 3 - j, 16).Value = Trim(Me.Controls("StoreClosed" & i).Text)
            End If
        Next i
       
        mysheet.Application.Windows(Dir$(cdlg.filename)).Visible = True
        mysheet.Application.ActiveWorkbook.Save
        mysheet.Application.ActiveWorkbook.Close
        xlApp.Quit
       
        Set mysheet = Nothing
        MsgBox "Excel file was successfully created!", vbOKOnly, "Done!"
        Me.Command33.Enabled = True
        Me.Command34.Enabled = True


How can I show progress bar while this code is working? I'm using  Microsoft Common Controls Progress Bar. Thanks.
0
Comment
Question by:Yury Merezhkov
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17916455
you put the progress bar on the form, say barProgress, and have it invisible


        barProgress.Min = 0
        barProgress.Value = 0
        barProgress.Max = 12
        barProgress.visible = true
        FileCopy SystemDir & "\Template.xls", cdlg.filename
       
        Set xlApp = CreateObject("Excel.Application")
        Set mysheet = xlApp.Workbooks.Open(cdlg.filename).Sheets(1)
           
        mysheet.Cells(4, 1).Value = Trim(Me.StoreName.Text)
        mysheet.Cells(4, 2).Value = Trim(Me.StoreNumber.Text)
        mysheet.Cells(4, 3).Value = Trim(Me.StoreHours.Text)
        mysheet.Cells(4, 4).Value = Trim(Me.SetPoint.Text)
        mysheet.Cells(4, 5).Value = Trim(Me.Days.Text)
        mysheet.Cells(4, 6).Value = Trim(Me.Employee.Text)
        mysheet.Cells(4, 7).Value = Trim(Me.preOpen.Text)
        mysheet.Cells(4, 8).Value = Trim(Me.Open.Text)
        mysheet.Cells(4, 9).Value = Trim(Me.preClose.Text)
        mysheet.Cells(4, 10).Value = Trim(Me.Unoccupied.Text)
        mysheet.Cells(4, 11).Value = Trim(Me.StoreContact.Text)
        mysheet.Cells(4, 12).Value = Trim(Me.Address.Text)
       
        j = 0
       
        For i = 1 To 12
           barProgress.Value = i
           doevents
            If (IsNull(Trim(Me.Controls("DateStart" & i).Text)) Or Trim(Me.Controls("DateStart" & i).Text) = "" Or Trim(Me.Controls("DateStart" & i).Text) = "__/__/____") And _
               (IsNull(Trim(Me.Controls("DateEnd" & i).Text)) Or Trim(Me.Controls("DateEnd" & i).Text) = "" Or Trim(Me.Controls("DateEnd" & i).Text) = "__/__/____") And _
               (IsNull(Trim(Me.Controls("StoreOpen" & i).Text)) Or Trim(Me.Controls("StoreOpen" & i).Text) = "" Or Trim(Me.Controls("StoreOpen" & i).Text) = "__:__ __") And _
               (IsNull(Trim(Me.Controls("StoreClosed" & i).Text)) Or Trim(Me.Controls("StoreClosed" & i).Text) = "" Or Trim(Me.Controls("StoreClosed" & i).Text) = "__:__ __") Then
                j = j + 1
            Else
                mysheet.Cells(i + 3 - j, 13).Value = Trim(Me.Controls("DateStart" & i).Text)
                mysheet.Cells(i + 3 - j, 14).Value = Trim(Me.Controls("DateEnd" & i).Text)
                mysheet.Cells(i + 3 - j, 15).Value = Trim(Me.Controls("StoreOpen" & i).Text)
                mysheet.Cells(i + 3 - j, 16).Value = Trim(Me.Controls("StoreClosed" & i).Text)
            End If
        Next i
       
        mysheet.Application.Windows(Dir$(cdlg.filename)).Visible = True
        mysheet.Application.ActiveWorkbook.Save
        mysheet.Application.ActiveWorkbook.Close
        xlApp.Quit
       
        Set mysheet = Nothing
        MsgBox "Excel file was successfully created!", vbOKOnly, "Done!"
        Me.Command33.Enabled = True
        Me.Command34.Enabled = True
       barProgress.visible = false
0
 
LVL 7

Author Comment

by:Yury Merezhkov
ID: 17916628
Progressbar becomes visible but nothing is happening in it. Then it just disappears.
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 17916722
did you put the line doevents?
note that working on only 12 cells should not really need a progress bar that will be done very fast anyhow.


        barProgress.Min = 0
        barProgress.Value = 0
        barProgress.Max = 7
        barProgress.visible = true
        FileCopy SystemDir & "\Template.xls", cdlg.filename
       
        Set xlApp = CreateObject("Excel.Application")
        barProgress.Value = 1
        doevents
        Set mysheet = xlApp.Workbooks.Open(cdlg.filename).Sheets(1)
           
        barProgress.Value = 2
        doevents
        mysheet.Cells(4, 1).Value = Trim(Me.StoreName.Text)
        mysheet.Cells(4, 2).Value = Trim(Me.StoreNumber.Text)
        mysheet.Cells(4, 3).Value = Trim(Me.StoreHours.Text)
        mysheet.Cells(4, 4).Value = Trim(Me.SetPoint.Text)
        mysheet.Cells(4, 5).Value = Trim(Me.Days.Text)
        mysheet.Cells(4, 6).Value = Trim(Me.Employee.Text)
        mysheet.Cells(4, 7).Value = Trim(Me.preOpen.Text)
        mysheet.Cells(4, 8).Value = Trim(Me.Open.Text)
        mysheet.Cells(4, 9).Value = Trim(Me.preClose.Text)
        mysheet.Cells(4, 10).Value = Trim(Me.Unoccupied.Text)
        mysheet.Cells(4, 11).Value = Trim(Me.StoreContact.Text)
        mysheet.Cells(4, 12).Value = Trim(Me.Address.Text)

        barProgress.Value = 4
        doevents
       
        j = 0
       
        For i = 1 To 12
            If (IsNull(Trim(Me.Controls("DateStart" & i).Text)) Or Trim(Me.Controls("DateStart" & i).Text) = "" Or Trim(Me.Controls("DateStart" & i).Text) = "__/__/____") And _
               (IsNull(Trim(Me.Controls("DateEnd" & i).Text)) Or Trim(Me.Controls("DateEnd" & i).Text) = "" Or Trim(Me.Controls("DateEnd" & i).Text) = "__/__/____") And _
               (IsNull(Trim(Me.Controls("StoreOpen" & i).Text)) Or Trim(Me.Controls("StoreOpen" & i).Text) = "" Or Trim(Me.Controls("StoreOpen" & i).Text) = "__:__ __") And _
               (IsNull(Trim(Me.Controls("StoreClosed" & i).Text)) Or Trim(Me.Controls("StoreClosed" & i).Text) = "" Or Trim(Me.Controls("StoreClosed" & i).Text) = "__:__ __") Then
                j = j + 1
            Else
                mysheet.Cells(i + 3 - j, 13).Value = Trim(Me.Controls("DateStart" & i).Text)
                mysheet.Cells(i + 3 - j, 14).Value = Trim(Me.Controls("DateEnd" & i).Text)
                mysheet.Cells(i + 3 - j, 15).Value = Trim(Me.Controls("StoreOpen" & i).Text)
                mysheet.Cells(i + 3 - j, 16).Value = Trim(Me.Controls("StoreClosed" & i).Text)
            End If
        Next i
       
        barProgress.Value = 5
        doevents
        mysheet.Application.Windows(Dir$(cdlg.filename)).Visible = True
        mysheet.Application.ActiveWorkbook.Save
        mysheet.Application.ActiveWorkbook.Close
        barProgress.Value = 6
        doevents
        xlApp.Quit
       
        barProgress.Value = 7
        doevents
        Set mysheet = Nothing
        MsgBox "Excel file was successfully created!", vbOKOnly, "Done!"
        Me.Command33.Enabled = True
        Me.Command34.Enabled = True
       barProgress.visible = false
0
 
LVL 7

Author Comment

by:Yury Merezhkov
ID: 17917225
Perfect! Thanks.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

596 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question