I store a website in the registry. For example:
SOFTWARE\Microsoft\Internet Explorer\Default Website
Key name: Website
Key value: www.google.com/
Then I try to create search plugin in IE.
Below is the code I use for that. It works for Google when I hard-code it,
but i want to use the registry value to set this variable.
<html>
<script language="VBSCRIPT">
set parentwin = external.menuArguments
str = trim(parentwin.document.selection.createRange().text)
bnewwindow = parentwin.event.shiftKey
defaultWebsite = ????????
url = defaultWebsite +"search?q=" + escape(str)
if(bnewwindow) then
window.open(url)
else
parentwin.window.navigate(url)
end if
</script>
</html>
You can use the Shell object to read and write registry values. You may get a warning in Internet Explorer when trying to instantiate an ActiveX control, since this requires access to the client PC.
' This uses HKCU. Change to HKLM, if you need.
Dim strKey = "HKCU\Software\Microsoft\Internet Explorer\Default Website\Website"
With CreateObject("WScript.Shell")
defaultWebsite = .RegRead(strKey)
End With
Related
Been using this code for a while to upload a file to SharePoint and noticed the other day that when the file is uploaded, it is checked out to myself automatically and have to go into SharePoint and manually check-in so that others can view the file. Any way to modify or add to my code below to auto check-in a file after it uploads? Totally stumped and any help would be greatly appreciated.
Sub SharePointUpload()
Dim WSN
Dim spAdd
Set WSN = CreateObject("WScript.Network")
spAdd = "https://mysharepoint/test"
WSN.mapnetworkdrive "N:", spAdd
ActiveWorkbook.Save
Dim SharepointAddress As String
Dim LocalAddress As String
Dim objNet As Object
Dim FS As Object
' Where you will enter Sharepoint location path
SharepointAddress = "\\mysharepoint\test"
' Where you will enter the local file path
LocalAddress = "C:\data\sample_file.xlsm"
Set objNet = CreateObject("WScript.Network")
Set FS = CreateObject("Scripting.FileSystemObject")
If FS.FileExists(LocalAddress) Then
FS.CopyFile LocalAddress, SharepointAddress
Else: MsgBox "File does not exist!"
End If
Set objNet = Nothing
Set FS = Nothing
WSN.removenetworkdrive "N:"
End Sub
I had the same issue with our SharePoint Document library even with option Require Check Out switched off - some documents (Word, Excel) were uploaded as Checked Out automatically (green arrow mark) whereas others were in fact Checked In from upload. Moreover when I wanted to Check In manually such documents, I got error message about missing mandatory field, although there was no field in the library set as mandatory.
The reason in my case was the field Title. This field is presented in library as default text field and it is also presented in Office files. I noticed that for Office files with empty field Title the document is automatically Checked Out during upload. When uploaded document contained some text in Title property, no Check Out was set. I also tried to use workflow to change the Title and then Check Out file (after creation), but it was not working - initial Check In was required to start the workflow. Manual change of document properties works but that's too tedious...
The first programmatic option to handle this issue could be to fill Title property of uploaded document when empty (i.e. add file name or any other text). Should work well with many languages. Example with Python:
from docx import Document
path = 'D:/myfile.docx'
document = Document(path)
document_property = document.core_properties
if not document_property.title:
document_property.title = 'Everything is Awesome'
document.save(path)
In VBA Title should accessible via Wb.BuiltinDocumentProperties("Title").
Another successful option for me was to find column Title in Columns of Document library and rename it to something else (I used Titlex as new name), then try to upload new document with empty Title - this time there was no automatic Check Out for the uploaded document. Then I could set the Titlex back to Title without returning the issue.
I'm trying to generate document links from another form using a button I created (in pass through below). Upon clicking the button, an agent must run and document link/s should be generated, and the current form should still be in edit mode (web).
Here are the issues:
1. I am unable to generate document link/s coming from another form through the view. The key is PeopleID, the current document has the computed field which should match with another form.
2. When I click on the button, it redirects me to the agent page and says that the agent is done running (non-verbatim). It should still be on the current document (current page, only that the document link/s should be generated).
Below is the code I use on the form (in pass-through) for the button and JS function to run agent.
<input type="button" value="Generate Link" onclick="javascript:runAgent();">
<script language="JavaScript">
function runAgent() {
var path = document.forms[0].BaseLink.value; // BaseLink is the prefix url.
var completeUrl = path + '(GenerateDoc)?OpenAgent&UNID=' + document.forms[0].UniqueID.value;
self.location.href = completeUrl;
}
</script>
After this, I have a rich text field named "DocumentLink", computed.
For the agent code, here it is:
Dim session As New NotesSession
Dim db as NotesDatabase
Dim curDoc as NotesDocument
Dim difDoc as NotesDocument
Dim view as NotesView
Dim rtitem as NotesRichTextItem
Dim peopleID as String
Set db = session.currentDatabase
thisDocumentID = Right$(session.DocumentContext.query_string(0),32)
Set curDoc = db.GetDocumentByUNID(thisDocumentID) //For some reason I am not getting anything here.
Set view = db.GetView("MyView")
peopleID = curDoc.PeopleID(0)
Set difDoc = view.GetDOcumentByKey(peopleID,true)
If Not difDoc Is Nothing Then
Set rtitem = curDOc.GetFirstItem("DocumentLink")
rtitem.values = ""
Call rtitem.AppendDocLink(difDoc,"Link to other form")
Call curDoc.Save(True,False)
End If
Appreciate your help.
There are several issues with what you are doing.
First: The self.location.href = completeUrl; line in Javascript will redirect the browser to the agent which has no relationship to the currently selected or open document. Alternatives to this approach would be using AJAX techniques from jQuery or other framework to run your agent asynchronously. If you have not saved the current document then there might not be a UNID on the Query String using your current approach.
Second: You should put the PeopleId on the query string also so that the agent can read it. The agent should then parse the Query_String_Decoded to get the two elements UNID and PeopleId.
Third: your agent is not generating any output. You should use PRINT statements in the LotusSctipt to create some feedback. You can also create JavaScript Tags and calls to calls to redirect back to the original page/document.
I have a particular FolderID and I'd like to upload files to this directory. (I have the reference to the iManage.dll and ImanEXTLib).
I'm struggling with filling out certain fields in the dialog/import window from the code level.
Ideally, I would like to skip this stage to make the upload faster. If I'm conveying all the required data then I can't see any point in the dialog besides clicking OK.
This is the code:
I'm locating the folder by using ManDMS.CreateSearchParameters
After getting results:
Dim rslts as IManFolders
Set rslts = IManSession.WorkArea.SearchFolders(<ManStrings>,<SearchParameters>)
If rslts.Empty = True Then
MsgBox "Found shit."
Elseif rslts.Empty = False Then
Dim TgtFdr as ImanFolder
Set impCmd = ImportCmd
Set context = New ContextItems
Set TgtFdr = rslts.ItemByIndex(1)
Now I'm setting the context items but I have the problem with Matter and Subclass. These are obligatory for the upload but the fields remain empty and I don't know how to address them to complete the upload:
context.Add("IManDestinationObject", TgtFdr)
context.Add("IManExt.Import.DocAuthor", UserID)
context.Add("IManExt.Import.DocDescription", file Name)
context.Add("IManExt.Import.FileName", file path)
context.Add("IManExt.Import.DocClass", "some info")
context.Add("IManExt.Import.DocSubclass", "some info")
context.Add("IManExt.Import.DocMatter", "some info")
impCmd.Initialize context
impCmd.Update
If impCmd.Status = IMANEXTLib.CommandStatus.nrActiveCommand Then
impCmd.Execute
Else
Endif
Tried different things - MatterID, MatterDesc, Custom1,2,3,. Is it possible to skip the part with this window and upload the file in a more straightforwrd way? Also, is it possible to to take out the doc number of the newly imported file at the end?
I tried:
UplDoc = (ImanDocument)context.Item("ImportedDocument")
I figured the whole thing out.
Sort of... I went into the object browser and managed to go around the problem and take advantage of the .DuplicateProfileFromDoc method. I simply mirror the profile of the uploaded doc from other already stored on worksite.
The last bit also solved.
It should be:
Set UplDoc = context.Item("ImportedDocument")
Cheers!
In my Test Plan I have two folders. One with all my active test cases and one with all my archived test cases. I need to replace a lot of 'Affected Module' from one value to another, however - I don't want the folder with archived to be affected by this.
So, is there a way of doing search and replace only on a specific folder (and all the sub-folders) in HP ALM?
As far as I know the search and replace function in grid view replaces all instances of the value so I can't use that directly.
Here is a simple OTA code that updates the field ts_user_04 for all the test case in folder Subject\Automated and its sub-folder from whatever value to Quoting.
Please, change the column name as per your requirement. You can easily find the DB column for any field in HP ALM by going to the Management tab if you have access to it. Even otherwise you can get all the mapping by using OTA. (I hope you have the necessary access)
Inorder to run the OTA code, you need to install ALM Connectivity add-in which you can get it from the tools section in your ALM home page
Public TDconnection
Public reqPath
Public testPath
'Call the main Function
updateAllTests
Public Function login()
Dim almURL, almUserName, almPassword, domain, project
almURL = "https://.saas.hp.com/qcbin/"
almUserName = ""
almPassword = ""
domain = ""
project = ""
testPath = "Subject\Automated" ' Change it as per your folder structure
Set TDconnection = CreateObject("tdapiole80.tdconnection")
TDconnection.ReleaseConnection
TDconnection.InitConnectionEx almURL
TDconnection.login almUserName, almPassword
TDconnection.Connect domain, project
End Function
Public Function updateAllTests()
login
Set TreeMgr = TDconnection.TreeManager
Set TestTree = TreeMgr.NodeByPath(testPath)
If Err.Number = 0 Then
Set comm = TDconnection.Command
comm.CommandText = "update test set ts_user_04='Quoting' where ts_test_id in (select ts_test_id from test, all_lists where ts_subject in (select al_item_id from all_lists where al_absolute_path like (select al_absolute_path from all_lists where al_item_id=" & TestTree.NodeID & ") || '%' ) and ts_subject = al_item_id)"
comm.Execute
End If
logout
MsgBox "Flag Update successful", vbInformation
End Function
Public Function logout()
TDconnection.Disconnect
TDconnection.logout
TDconnection.ReleaseConnection
Set TDconnection = Nothing
End Function
I have a domino application with XPages that i want to be public. So, i set in the ACL the "Default" to Depositor level with read public documents option, so as to make it public.
When i want to use an image resource i go to its properties security tab and i enable the "available to public access users" checkbox.
Now, I want to use font-awesome in my application and i have font-awesome's folder with its subfolders and files under webcontent folder.
How can i make them public? (in a non-public app, font-awesome works normally with font-awesome's folder under webcontent folder)
I simply created an agent to set the flag. You can get the code below. I use it for an Angular app that I have added to the NSF.
HTH
/John
Edit:
Code inserted directly here:
Option Public
Option DeclareSub Initialize
Const APP_DIR = “app/”
Const FN_PUBLICACCESS = “$PublicAccess”
Const FLAG_TRUE = “1”
Dim sess As New NotesSession
Dim db As NotesDatabase
Dim nc As NotesNoteCollection
Set db = sess.currentDatabase
Set nc = db.CreateNoteCollection(False)
Call nc.SelectAllDesignElements(True)
Call nc.BuildCollection
Dim d1 As Long
Dim d2 As Long
Dim title As String
Dim flagsExt As String
Dim noteid As String
Dim nextid As String
Dim i As Long
Dim doc As NotesDocument
noteid = nc.Getfirstnoteid()
For i = 1 To nc.Count
‘get the next note ID before removing any notes
nextid = nc.GetNextNoteId(noteid)
Set doc = db.GetDocumentByID(noteid)
title = doc.GetItemValue(“$title”)(0)
flagsExt = doc.GetItemValue(“$flagsExt”)(0)
If LCase(flagsExt) = “w” And Left(LCase(title),Len(APP_DIR)) = LCase(APP_DIR) Then
d1 = d1 + 1
If Not doc.Getitemvalue(FN_PUBLICACCESS)(0) = FLAG_TRUE Then
d2 = d2 + 1
Call doc.replaceItemValue(FN_PUBLICACCESS,FLAG_TRUE)
Call doc.save(True, False)
Print title & ” – set to allow public access read”
End If
End If
noteid = nextid
Next
Print nc.count & ” design elements checked. “ & d1 & ” elements found in ‘” & APP_DIR & “‘ and “ & d2 & ” updated to give public access”
End Sub
They still get registered as design notes inside the NSF (which is why they're picking up the default visibility), so I think the only real option is to run an agent to update their visibility, explicitly. Sven Hasselbach has blogged about this topic a couple times (at least on interacting with items in the WebContent folder, programmatically) and is worth reading. Ultimately, I try to put these sorts of public agnostic, common resources into my Domino /Data/domino/html/ path, so as to have it always public (that path is always publicly visible), and available to be set in a theme .
[Update]
See the link Per Henrik Lausten posted in the comments to the Q for details.
[/Update]