I'm looking through at an old Classic ASP page that uses VBScript. The code below appears to use a variable stored in the config (global.asa) called called CODES_TIMESTAMP. However looking at the servers in question it appears that that variable no longer exists. My question is, if that variable is not defined in the config file then will the error message box be activated?
Dim DB_TIMESTAMP_CODES
DB_TIMESTAMP_CODES = "<%=Application("CODES_TIMESTAMP")%>"
If trim(DB_TIMESTAMP_CODES) = "" Then
msgbox "Setup Error... Codes are not Defined"
End If
My question is, if that variable is not defined in the config file then will the error message box be activated?
Value will be "". But msgbox cannot be executed on ASP web page. msgbox will appear only from VBS script.
The code below appears to use a variable stored in the config (global.asa) called called CODES_TIMESTAMP
You (previous developer) could assign value to Application variable from any page. I suggest you to make full search over all .ASP pages, may be this value assigned not in GLOBAL.ASA
Related
I am running a Sub procedure stored in an ACCESS database using VBScript. The procedure queries the database and exports/saves a CSV file.
My problem is that the script successfully opens the database, runs the procedure but then leaves ACCESS open because ACCESS opens a prompt asking "Are you sure that you want to leave ACCESS" (rather its equivalent in German). I want it to close without interaction.
The basic idea of this script is to run it via the Windows Task Scheduler. (Which does not work right now but that is another question.)
Here is the part of my VBScript dealing with the ACCESS database:
Dim objAccess
Set objAccess = createObject("Access.Application")
objAccess.OpenCurrentDataBase("C:\FiselTools\Allgemein\Scripte\Pellenc-CopyBelegarchiv3.accdb")
objAccess.Run "CopyBelegarchiv"
objAccess.Quit acQuitSaveAll
Set objAccess = Nothing
Using this script manually, it does open the database, export the file, finally executes the part following the code from above - so only closing ACCESS does not work and my guess is that it's not a problem with the script or the procedure but the ACCESS.
Erik A basically gave the right answer: there was some VBA code that is responsible for this prompt (see below). It was part of the primary form.
So in this case I found two possible solutions:
Do not display/show the form (which worked for me as I made a copy of the file dedicated for just this purpose).
If you need the form then you might need to delete the VBA code.
Private Sub Form_Unload(Cancel As Integer)
Dim Answer As Variant
Answer = MsgBox("Wollen Sie die Anwendung wirklich beenden?" & vbNewLine & vbNewLine & "Nicht gespeicherte Änderungen gehen dabei möglicherweise verloren", vbQuestion + vbYesNo + vbDefaultButton2)
If Answer = vbNo Then
Cancel = True
Else
DoCmd.Quit acQuitSaveNone
End If
End Sub
Since it is part of the Access class object of the form that is configured to be displayed on opening the ACCESS database and I do not need the form when I run the procedure via VBScript I simply changed the database to not display any form when the database is opened.
Some day I will remove any form, query, and any other object not needed from this special copy of the database that I don't need to run from VBScript.
Thanks!
I am executing the automated test scripts in UFT 12.5 I am new to UFT. Not very familiar with codes.There is an edit box wherein i have to type the value "S05292". Example:
Browser(Browsername").Page("Pagename").WebEdit("ctl00$ConBody$txtPDNumber").Set "S05292"
The problem is my script fails at this step and does not type the value. Can somebody provide me with a solution which is easy to understand. I tried the below two methods
Method (1)
a=Browser().page().webedit(ctl00$ConBody$txtPDNumber).getroproperty("value")
if a=="S05292" then
msgbox ("displayed message is S05292")
else
msgbox ("msg is not S05292")
end if
Method (2)
x = Browser("Browsername").Page("Pagename").Webedit("ctl00$ConBody$txtPDNumber").GetROProperty("value")
msgbox x
The error message that displays is
Cannot identify the object "ctl00$ConBody$txtPDNumber" (of class WebEdit).
Verify that this object's properties match an object currently displayed in your application.
Use the Object Spy to get the properties of that text box at run time and then make sure they match up to the properties of that text box in your object repository that you defined. Perhaps that don't match up or you didn't uniquely identify that text box.
If you don't want to use an object repository then you have to pass it a property at run time to uniquely identify it. Some thing like:
Browser().page().webedit("developer name:=PDNumber").
Instead of a .set you can do a .type to set/type the value into the text box
I have a VBScript that opens a Visio file in the background by using Visio.Application in invisible mode.
Set Visioapp = CreateObject("Visio.Application")
Visioapp.Visible = False
Set Visio = Visioapp.Documents.Open(VisioFile)
This works fine except when I try to open a file that generates a pop-up while I'm processing it. If that happens, the application would show an alert to notify the user but since the application is invisible to the user (or running without a user present), the script just hangs indefinitely, waiting for input that won't be coming.
If I were writing VBA code for Excel or Word I could use Application.DisplayAlerts = False (and/or possibly DisplayEvents). But in my VBScript the Visio application doesn't have that property. Visioapp.DisplayAlerts = False will give me the error "Object doesn't support this property or method".
How do I suppress the popups generated by a Visio application opened from VBScript?
Summarizing the comments from #Dave and #Noodles, the Visio Application object does not have a property DisplayAlerts like other Office applications have. Instead it provides a property AlertResponse that allows you to define whether the application should respond to alerts with OK, Cancel, Abort, Retry, …
To have the application respond with OK to all alerts change your code to something like this:
Set Visioapp = CreateObject("Visio.Application")
visioapp.AlertResponse = vbOk
Set Visio = Visioapp.Documents.Open(VisioFile)
Note that in this case you can use the symbolic constants that VBScript already provides (vbOk, vbCancel, vbAbort, vbRetry, …). For application-specific constants (e.g. the SaveFlags for the SaveAsEx method) this won't work, though. In those cases you'll have to either use the numeric value:
Visio.SaveAsEx "C:\path\to\output.vsd", 1
or define the constant in your script:
Const visSaveAsRO = 1
...
Visio.SaveAsEx "C:\path\to\output.vsd", visSaveAsRO
I am thoroughly stumped by this problem. I have some standard functions that I saved in a compiled AppleScript file, let's call it functions.scpt. In another script, I use load script to load a script object to functions.scpt:
set funcs to load script "path/to/functions.scpt
I have one handler in functions.scpt called icon(). For whatever reason, if I try to call this function more than once in my other script, I get an error. Here's some quick example code:
--called once
funcs's icon()
--called twice
funcs' icon()
Whenever I do this, I get the following error: error "«script» doesn’t understand the “icon” message." number -1708 from «script» to «class icon».
Why can't I call the same function from a loaded script object twice? How can I fix this? I need to call it multiple times.
Thank you to #CRGreen and #jweaks. I actually just found the answer on this thread: https://stackoverflow.com/a/13256042/2884386
I had set a variable icon within the handler, which was overwriting the handler. So when the other script tried to access it the second time, it wasn't pointing to the handler, but to the variable. I rewrote the internal variables, and that fixed it.
So, this is (as an example) correct:
on icon()
set _icon to "path/to/icon.png"
return POSIX file _icon
end icon
Whereas this is incorrect:
on icon()
set icon to "path/to/icon.png
return POSIX file icon
end icon
I have an Image object.
I have the Picture type set to linked, so I can change the picture if I want.
I have the Picture property set to the picture name.
I would think that access would use relitive addressing and simple looking in the current directory for the image. But it does not and I get an error telling me it cannot find the picture.
Anyone have a solution? (Other than setting the Picture type to embedded or using the full file address?)
Thanks!
Update:
Tried this:
Private Sub Form_Load()
Dim file As String
file = CurrentDb().Name
file = Replace(file, ".mdb", ".bmp")
Me.Image46.Picture = file
End Sub
It works, except I still get the error message. I click O.K. and it works. Just need the error message to go away.
SOLUTION: Use the above code (or the code posted in the answer below) and then set the 'picture type' to "embedded" and then delete the 'picture' field so that it says "(none)".
Save and run.
It should work.
THANKS!
You could set the property on the forms OnLoad event like this
Me.imgMy_image.picture=getDBPath & “mypicture.bmp”
Here is the getDBPath function
Public Function GetDBPath() As String
Dim strFullPath As String
Dim I As Integer
strFullPath = CurrentDb().Name
For I = Len(strFullPath) To 1 Step -1
If Mid(strFullPath, I, 1) = "\" Then
GetDBPath = Left(strFullPath, I)
Exit For
End If
Next
End Function
Before anyone comments yes I know in access 2000 and above you can use currentproject.path but I’m stuck in the land that time forgot so need that custom function, it still works with later versions of access
Current folder depends of the way you open database in Access. At least, if you open it thru "File-Open", current folder changes to the folder of MDB file. But if you open via double-clicking MDB in explorer, it does not.