Excel 2010, how to disable prompt "open as read only?" on opening a worbook which previously saved as with "read only recommended"? - excel-2010

I saved as a workbook without password but mark the "Read only recommended".
When I open this read_only_workbook (by double clicking the file), it prompt me like below picture :
Since what I want is "just open it directly in read only mode - do not show any prompt or pop-up message", so my question is : how do I disable that pop-up prompt ? --- or in another way : how to save a workbook as readonly which if later a user open the workbook (by double clicking the file) it won't show any pop-up window?
What I've tried so far (by guessing), before save as a read only workbook, I put a code in the workbook module like this :
Private Sub Workbook_Open()
Application.DisplayAlerts = False
ThisWorkbook.ReadOnly = True
End Sub
But the prompt is shown first before it trigger the Workbook_Open event.

Related

How to Paste URL in address bar of new tab in Java Selenium?

I want to paste a url in java selenium. This Url is created by clicking on copy to clipboard button, which copies the code.
What I did is in below code :
Wrote code for Generate link which works fine
//Click on Generate link
logger.trace(" Clicking on generate link button");
By generate_link_button = By.xpath(prop.getProperty("generate_link")); //getting xapth from config.properties file
explicit_wait.until(ExpectedConditions.elementToBeClickable(generate_link_button));
driver.findElement(generate_link_button).click();
logger.trace(" Clicking on generate link button done");
java.lang.Thread.sleep(2000);
// Then I wrote code by clicking on copy to clipboard button (This code also works fine)
logger.trace(" Clicking on copy to clipboard button");
By copy_to_clipboard_button = By.xpath(prop.getProperty("copy_to_clipboard"));//getting xapth from config.properties file
explicit_wait.until(ExpectedConditions.elementToBeClickable(copy_to_clipboard_button));
driver.findElement(copy_to_clipboard_button).click();
logger.info(" Clicking on copy to clipboard button done sucessfully");
java.lang.Thread.sleep(2000);
//Then Wrote code for opening a new tab (this code also works fine)
((JavascriptExecutor)driver).executeScript("window.open();"); //opening a new tab in chrome browser
//Now the issue is seen from here
Actions actions = new Actions(driver);
actions.sendKeys(Keys.chord(Keys.LEFT_CONTROL, "v")).build().perform();
Error is seen as : org.openqa.selenium.NoAlertPresentException: no such alert
Note:all imports are done.
I need to paste the url which is generated after clicking on copy to clipboard and that URL I need to paste in the new tab and press enter.My code from action class is not working.
Any feedback for this?

How to run an Applescript that will click and open all links on a web page?

I'm trying to write a script that will automatically open a webpage http://www.legislation.gov.uk/new/uksi and then click on all the links in the table "All New Legislation".
So far I've managed to get it to open the page but no luck with clicking.
Here's my script so far:
activate application "Safari"
open location "http://www.legislation.gov.uk/new/uksi"
to clickID()
do JavaScript "document.getElementById(id=per).click();" in document 1
end tell
The following example AppleScript code will open the targetURL in a new Safari window, wait for the page to finish loading, retrieve all URLs on the target page, search them for URLs pointing the various Statutory Instruments published today, and then open each one in a new tab of the same window the targetURL was opened.
set targetURL to "http://www.legislation.gov.uk/new/uksi"
set theseURLs to {}
set grepSearchPattern to ".*\\.uk/uksi/.*\\|.*\\.uk/ssi/.*\\|.*\\.uk/wsi/.*\\|.*\\.uk/nisi/.*"
set jsStatements to "var a = document.links; var x = ''; var i; for (i = 0; i < a.length; i++) { x = x + a[i].href + '|'; };"
tell application "Safari"
make new document with properties {URL:targetURL}
activate
end tell
tell application "System Events"
repeat until exists ¬
(buttons of UI elements of groups of toolbar 1 of window 1 of ¬
process "Safari" whose name = "Reload this page")
delay 1
end repeat
end tell
tell application "Safari"
set allURLs to (do JavaScript jsStatements in document 1)
end tell
try
set theseURLs to paragraphs of (do shell script "tr '|' '\\12' <<< " & ¬
allURLs's quoted form & " | grep " & grepSearchPattern's quoted form)
end try
if (length of theseURLs) is greater than 0 then
tell application "Safari" to tell front window
repeat with thisURL in theseURLs
set current tab to (make new tab with properties {URL:thisURL})
end repeat
set current tab to first tab
end tell
else
display dialog " Nothing published on this date." buttons {"OK"} ¬
default button 1 with title "All New Legislation" with icon note
end if
Hint: Mouse over and horizontal/vertical scroll to see full code.
Notes:
The do JavaScript1 command create a pipe delimited string of all URLs on the page of the targetURL.
The do shell script command takes the pipe delimited string of all URLs and replaces the pipe characters with newline characters, using tr, so grep can return the URLs that match the grepSearchPattern.
The grepSearchPattern variable currently only searches for Statutory Instruments, as I assume that is all that will show under All New Legislation on the page the targetURL opens to, because of /new/uksi in the targetURL, and what I've observed at that URL since you posted the question. If you also want links for other types of legislation, the grepSearchPattern variable can be adjusted to accommodate.
1 Using the do JavaScript command requires Allow JavaScript from Apple Events to be checked on the Safari > Develop menu, which is hidden by default and can be shown by checking [√] Show Develop menu in menu bar in: Safari > Preferences… > AdvancedIf you are not allowed to enable that setting, the URLs can be collected for processing in another manner, however it uses the lynx third party utility.
Opening the links without the use of the do JavaScript command:
The following example AppleScript code will use lynx to retrieve the URLs from the targetURL, search them for URLs pointing the various Statutory Instruments published today, and if some have been published will open the targetURL in a new Safari window, wait for the page to finish loading, and then open each one in a new tab of the same window the targetURL was opened.
set targetURL to "http://www.legislation.gov.uk/new/uksi"
set theseURLs to {}
set lynxCommand to "/usr/local/bin/lynx --dump -listonly -nonumbers -hiddenlinks=ignore"
set grepSearchPattern to ".*\\.uk/uksi/.*\\|.*\\.uk/ssi/.*\\|.*\\.uk/wsi/.*\\|.*\\.uk/nisi/.*"
try
set theseURLs to paragraphs of ¬
(do shell script lynxCommand & space & targetURL's quoted form & ¬
" | grep " & grepSearchPattern's quoted form)
end try
if (length of theseURLs) is greater than 0 then
tell application "Safari"
make new document with properties {URL:targetURL}
activate
end tell
tell application "System Events"
repeat until exists ¬
(buttons of UI elements of groups of toolbar 1 of window 1 of ¬
process "Safari" whose name = "Reload this page")
delay 1
end repeat
end tell
tell application "Safari" to tell front window
repeat with thisURL in theseURLs
set current tab to (make new tab with properties {URL:thisURL})
end repeat
set current tab to first tab
end tell
else
display dialog " Nothing published on this date." buttons {"OK"} ¬
default button 1 with title "All New Legislation" with icon note
end if
Hint: Mouse over and horizontal/vertical scroll to see full code.
Notes:
In the lynxCommand variable, change /usr/local/bin/lynx to the appropriate /path/to/lynx. lynx can be installed using Homebrew
The grepSearchPattern variable currently only searches for Statutory Instruments, as I assume that is all that will show under All New Legislation on the page the targetURL opens to, because of /new/uksi in the targetURL, and what I've observed at that URL since you posted the question. If you also want links for other types of legislation, the grepSearchPattern variable can be adjusted to accommodate.
Note: The example AppleScript code is just that and sans any included error handling does not contain any additional error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors.

Programmatically open a UserForm from an external script / program / host application

Given that I have a UserForm embedded in one of the following:
an Excel workbook named c:\myBook.xslm
a Word document c:\myDocument.docm, or
a PowerPoint presentation named c:\myPresentation.ppm
What Automation properties / methods do I need to use in order to open and display the UserForm from an external script / host application / program?
For example, let's say I have the following JScript running under WSH:
var app = new ActiveXObject('Excel.Application');
app.Visible = true;
var book = app.Workbooks.Open('c:\myBook.xlsm');
// open UserForm here
How would I proceed to open the UserForm?
Note: I am looking for a solution that would work with an arbitrary document. This precludes manually (but not programmatically as part of the script) adding a Sub to show the UserForm, which can be called from the external script.
An idea is to override the document open mehtods. At least for Microsoft Word and Excel:
' Word
Private Sub Document_Open()
UserForm1.Show
End Sub
' Excel
Private Sub Workbook_Open()
UserForm1.Show
End Sub
At word and excel document open, the dialog will be shown.
For Powerpoint its a bit more complicated:
How to auto execute a macro when opening a Powerpoint presentation?
Update
After additional information in the question this is not a solution anymore. A starting point how to create code an add it to a VBA project can be found here: https://stackoverflow.com/a/34838194/1306012
Also this website provides additional information: http://www.cpearson.com/excel/vbe.aspx

Umbraco 7 Upload File - Check if remove file is ticked

I have an Upload file option in Umbraco 7, the problem I have is if the remove checkbox is ticked and you click publish to remove the file, my code below catches the upload field as empty and display my custom error message.
if (string.IsNullOrEmpty(urlForFileUpload))
{
e.CancelOperation(new EventMessage("Error", "Please select an Excel file before publishing",EventMessageType.Error));
}
Does anyone know what gets passed to the server so that I can check for it and not display my error message if the checkbox is ticked?
--------------------CancelOperation---------------
You don't need an event handler to check that. Just make the field mandatory:

Ruby tool that pics a folder on the local drive?

Ok so i have a ruby script that currently prompts the user for a string location of a folder on the users harddrive ...this works well
puts "\nEnter the location of the files"
loop do
print "\nLocation: "
reply = ''
reply = STDIN.gets.strip
break if File.directory?(reply)
puts File.directory?(reply)
end
But i was wondering if there was another tool other then the STDIN (which currently makes the user enter a string of the path) that will popup a folder search that the user can navigate to ...if there is anything else I can provide for anyone to help you help me..
I can ever use rails if there is no other option but i have no idea whats available to me
There are a many Ruby GUI libraries; pick one--most will have a file dialog.
For simple dialogs, Zenity is fine.
This is a file selection dialog:
file = `zenity --file-selection --title="Select a file"`.chomp
Adding one parameter changes it to a directory selection dialog:
dir = `zenity --file-selection --directory --title="Select a directory"`.chomp

Resources