473,395 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Programmatically clicking "ok" on message box

41
Hi all, I am using Access to grab some data from a database and plot a graph in Excel. When I do this, there is a message box in Excel that pop ups with an initialization error, that asks me to click ok - however the data that I want is already in the worksheet.

Is there a way to automate the "ok" so that I don't need click it every time I generate one of these sheets? I generate 13 at a time. I have tried the

application.DisplayAlerts = false

but it doesn't work. Any ideas? Thanks in advance!
Nov 16 '07 #1
5 6256
FishVal
2,653 Expert 2GB
Hi, cloh.

Could you post your code (I guess)?
Nov 16 '07 #2
cloh
41
Hey, don't know if this will help (the code is very long and convoluted) but this is where I am trying to "hide" the messagebox...

Expand|Select|Wrap|Line Numbers
  1. Public Sub ProcessGUIClick(gui As Form, Optional destFolderPath As String)
  2.     Dim fdialog As FileDialog
  3.     Dim result As Integer
  4.     Dim gui As Form
  5.     Set gui = Form_LocbyCcy
  6.     Set fdialog = Application.FileDialog(msoFileDialogFolderPicker)
  7.         With fdialog
  8.         .AllowMultiSelect = False
  9.         .ButtonName = "Select"
  10.         If .Show = -1 Then
  11.             Excel.Application.DisplayAlerts = False
  12.             createGlobalCcys destFolderPath:=.SelectedItems(1)
  13.             createImpCcys destFolderPath:=.SelectedItems(1)
  14.             Excel.Application.DisplayAlerts = True
  15.             OpenChart39 destFolderPath:=.SelectedItems(1)
  16.             Call MakeCharts
  17.         End If
  18.     End With
  19. End Sub
Nov 16 '07 #3
cloh
41
This is a sample of the "createGlobalccys" function - the "other createImpCcys" is similar:

Expand|Select|Wrap|Line Numbers
  1. Public Sub createGlobalCcys(Optional destFolderPath As String)
  2.     Dim xlapp As Excel.Application
  3.     Dim fso As New FileSystemObject
  4.     Dim newFolder As Folder
  5.     Dim Filename As String
  6.     Dim gui As Form
  7.     Dim Date1val As String
  8.     Dim Date2val As String
  9.     Dim Date1value As String
  10.     Dim Date2value As String
  11.  
  12.     Set gui = Form_LocbyCcy
  13.     Date1val = gui.txt_FromDate.value
  14.     Date2val = gui.txt_ToDate.value
  15.     Date1value = DateAdd("d", -1, Date1val)
  16.     Date2value = DateAdd("d", 1, Date2val)
  17.  
  18.     On Error Resume Next
  19.     Set xlapp = New Excel.Application
  20.     If Err <> 0 Then
  21.         MsgBox "Could not start Excel", vbExclamation
  22.         GoTo createGlobalCcys_err
  23.     End If
  24.  
  25.     If Not fso.FolderExists(destFolderPath) Then
  26.         MsgBox "Could find the specified folder!", vbExclamation
  27.         GoTo createGlobalCcys_err
  28.     Else
  29.         Set newFolder = fso.GetFolder(destFolderPath)
  30.     End If
  31.  
  32.     On Error GoTo createGlobalCcys_err
  33.  
  34.     Filename = fso.BuildPath(newFolder.path, "GlobalCcys.xls")
  35.  
  36.     CreateGlobalChart graphTypeID:=1, Date1:=Date1value, Date2:=Date2value, _
  37.             Filename:=Filename, xlAppRef:=xlapp
  38.  
  39. createGlobalCcys_exit:
  40.     Exit Sub
  41. createGlobalCcys_err:
  42.     MsgBox Err.Description
  43.     Resume Next
  44. End Sub
Nov 16 '07 #4
cloh
41
Sorry guys, with regards to this post basically all I need help with is the VB code to dismiss a msgbox. Any ideas?

Oh yeah, Happy Thanksgiving in advance!
Nov 16 '07 #5
FishVal
2,653 Expert 2GB
Several points:
  • are you sure the message is thrown by Excel ?
  • if you want to run method / set property of some particular object you should reference the object implicitely, code like
    Excel.Application.DisplayAlerts ....
    has a little chance to take an effect on your particular application instance
  • you should localize code line throwing the error, if you have difficulties debugging code then take a look at WIP: Debugging in VBA article
  • there is no simple method to close messagebox

P.S. Happy Thanksgiving.
Nov 16 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

23
by: ian justice | last post by:
Before i post actual code, as i need a speedyish reply. Can i first ask if anyone knows off the top of their head, if there is a likely obvious cause to the following problem. For the moment i've...
3
by: Jacob Larsen | last post by:
Is <select name="var"> ok according to w3.org? Regards Jacob
32
by: Will Hartung | last post by:
Can someone clarify that multiple classes in the "class" attribute are ok and "legal" and not some fluke? So, I can do: ..pink {color: pink} ..bold {font-weight: bold} ..medium {font-size:...
1
by: Gaz | last post by:
Hey. I looked at the Sendmail help and did not find a property where i can get an "ok" signal when the email is finally sent. I need something like that to show a "Processing, please stand by"...
1
by: Rich | last post by:
I have a simple vb2005 app (for testing). It is just a simple winform with one button that brings up a message box. When I invoke the app and click on the button, the message box comes up OK. ...
1
by: shaizaban | last post by:
hello, my question is as follows (very urgent): i generated in an aspx page a modalpopup ajax control. i inserted a user control into the panel contained in the popup control. the panel contains...
3
by: Lowrider | last post by:
I'm new to the VB programming world and am having a problem with flow control. In the code below I check 3 textboxes and display a messagebox if one or more are left blank. The problem lies in that...
2
Claus Mygind
by: Claus Mygind | last post by:
Is there a newer version of javaScript that will allow other text on the confirm dialogue box in place of "Ok" and "Cancel" Specifically for FireFox. I know that I can use visual basic for internet...
1
by: jalpari | last post by:
hi all, i have created a form in which i have a button for searching records from database, when a record is found it'z displayed in the table fields and whenever the record'z not found it displays...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.