I often (using the mouse) switch between 1 of 3 favorite folders under my inbox. I am looking to write a macro to switch between these folders. I see lots of emails on code to move specific emails to folders but is there a way to move focus on a specific folder?
Sure, you could just change the CurrentFolder value to one of your Inbox folders. Here's an example of changing views from wherever I am to a folder named "T1" which is under the Inbox.
Sub ChangeViewtoFolderT1()
Dim ns As Outlook.NameSpace
Set ns = Application.GetNamespace("MAPI")
Dim Exp As Outlook.Explorer
Set Exp = Application.ActiveExplorer
Dim myInbox As Folder
Set myInbox = ns.GetDefaultFolder(olFolderInbox)
Dim folder1 As Folder
Set folder1 = myInbox.Folders.Item("T1")
Set Exp.CurrentFolder = folder1
End Sub
See http://msdn.microsoft.com/en-us/library/bb220039.aspx for more details.
Related
Imagine I have a java_binary target triggered by a custom rule that generates source code and places the generated sources under a directory, let's call it "root".
So after the code generation we will have something like this:
// bazel-bin/...../src/com/example/root
root:
-> Foo.java
-> Bar.java
-> utils
-> Baz.java
Now, I have another target, a java_library, that depends on the previously generated sources, so it depends on the custom rule.
My custom rule definition currently looks something like this:
def _code_generator(ctx):
outputDir = ctx.actions.declare_directory("root")
files = [
ctx.actions.declare_file("root/Foo.java"),
ctx.actions.declare_file("root/Bar.java"),
ctx.actions.declare_file("root/utils/Baz.java"),
// and many,
// many other files
]
outputs = []
outputs.append(outputDir)
outputs.extend(files)
ctx.actions.run(
executable = // executable pointing to the java_binary
outputs = outputs
// ....
)
This works. But as you can see, every anticipated file that is to be generated, is hard-coded in the rule definition. This makes it very fragile, should the code generation produce a different set of files in the future (which it will).
(Without specifying each of the files, as shown above, Bazel will fail the build saying that the files have no generating action)
So I was wondering, is there a way to read the content of the root directory and automatically, somehow, declare each of the files as an output?
What I tried:
The documentation of declare_directory says:
The contents of the directory are not directly accessible from Starlark, but can be expanded in an action command with Args.add_all().
And add_all says:
[...] Each directory File item is replaced by all Files recursively contained in that directory.
This sounds like there could be a way to get access to the individual files in the directory, but I am not sure how.
I tried:
outputDir = ctx.actions.declare_directory("root")
//...
args = ctx.actions.args()
args.add_all(outputDir)
with the intention to access the individual files later from args, but the build fails with: "Error in add_all: expected value of type sequence or depset for values, got File".
Any other ideas on how to implement the rule, so that I don't have to hard-code each and every file that will be generated?
I am creating an invoice system and I am wanting to save the pdfs to google drive.
I set it up so that they would just all save to the same folder. Then I realized that I could make a folder for each individual customer. And by having the script pull the folder ID off of the Client List tab. (See it on column Q of sheet under Client List Tab)
However this means manually making a folder and doing for each new customer. So ideally the script would save each PDF to its own folder based on the name of the customer and create a new folder if there is no folder for that customer.
Is that possible? If so, any pointers to do so? Thanks!
Link for spreadsheet
https://docs.google.com/spreadsheets/d/1i3CXHR_EBal5_JAcoKKopNovySzvhmKVCVXXD7K9ke4/edit?usp=sharing
Assuming you have the client name in variable clientName:
const clients = SpreadsheetApp.getSheetByName('Client List').getDataRange().getValues();
const folders = {};
for (let i = 6; i < clients.length; i++) {
folders[clients[i][0]] = clients[i][16];
}
let folder;
const id = folders[clientName];
if (id) { folder = getFolderByIdDriveApp.getFolderById(id); }
else { folder = parentFolder.createFolder(clientName); }
You code can easily handle this.
I am going to assume that you have the customer number. The first thing your code should do would be to do a file.list and using the Q parm as you menotned search for a file with the name of customerNumber and the mime type of application/vnd.google-apps.folder This will give you the file id of that folder.
If it does not exist then you can do a file.create and set the mime type again to 'application/vnd.google-apps.folder'. This response will return you a file id.
Now you have the file id you can upload your file, and set parents to the file id that you just created.
When uploaded your file will be in the directory for that customer.
It is potentially a three step process but it will work.
However this means manually making a folder and doing for each new customer. So ideally the script would save each PDF to its own folder based on the name of the customer and create a new folder if there is no folder for that customer.
Thanks to help from people on Stack Overflow, I'm working on a huge program using Applescript, but I have gotten stuck at a part where I have made a new folder, and I am trying to move 2 illustrator files into it. Normally this wouldn't be a problem as I have moved file before after selected them with "choose", but this time I'm not selecting them I only have variables with their full paths.
So my question is how can I move the 2 files using their full paths?
Can I somehow manipulate the variables into a more manageable format?
This is the part of the code not working (the full thing is huge but I can post it if requested) and a few snippets of where variables got their values from
set saveLocation to ((path to desktop) as string) --place to save the files
set theFile to choose file --choose .ai file to get outlines on
tell application "Finder" to set fileName to name of theFile
set fullPath to (saveLocation & fileName) --file path of new .ai
make new folder at saveLocation with properties {name:(text 1 thru ((length of fileName) - 3) of fileName)}
tell current application
set newFolder to POSIX path of saveLocation
set newFolder to newFolder & (text 1 thru ((length of fileName) - 3) of fileName)
*--set newFolder to choose folder* -- I tested to see if manually selecting the new folder helped, it didn't
move fullPath to newFolder
I really appreciate any help, thanks in advance
Very simple, set the make folder to a variable to call later. Looks like this:
tell app "finder" --need to use Finder to move files
set somevariable to make new folder at saveLocation with properties {name:(text 1 thru ((length of fileName) - 3) of fileName)}
move file fullPath to folder somevariable
end tell
I am going to create a self extracting archive but I have got a problem connecting with the default path of the extraction. I would like to extract my files in the same path as the self-extraction archive program. Unfortunately, the files are extracting in another path (C:\Users\computer\AppData\Temp\IXP000.TMP). Is it possible to set the path?
I can't find any direct way to do this with IExpress, but there is a trick we can apply.
But first I'll point out that this is really easy with something like 7-Zip's 7zCon.sfx module (if all you need to do is have the archive extract to the current directory, no questions asked). So you might just want to try something other than IExpress.
Anyhow, the problem with IExpress is that, at the time our install program runs, we're no longer in the directory of the original archive; the current directory is now something like %temp%\IXP000.TMP. So we need to find the directory of our parent process – kind of a pain. Once that's known, we can just xcopy the contents of the archive over to the destination folder.
In VBScript, it would look something like this:
Option Explicit
Dim objShell, objWMI
Dim objCmd, intMyPid, intMyParentPid, objMyParent
Set objShell = CreateObject("WScript.Shell")
Set objWMI = GetObject("winmgmts:root\cimv2")
Set objCmd = objShell.Exec("cmd.exe")
intMyPid = objWMI.Get("Win32_Process.Handle='" & objCmd.ProcessID & "'").ParentProcessId
objCmd.Terminate
intMyParentPid = objWMI.Get("Win32_Process.Handle='" & intMyPid & "'").ParentProcessId
Set objMyParent = objWMI.Get("Win32_Process.Handle='" & intMyParentPid & "'")
objShell.Run "xcopy /y * " & """" & Left(objMyParent.ExecutablePath, _
InStrRev(objMyParent.ExecutablePath, ".exe", -1, vbTextCompare) -1) &_
"\""", 0, True
Your install program would then be, eg: wscript extractToOriginalLocation.vbs //B.
(Inspired somewhat by the answer to this question.)
You could always use a cmd script and echo lines of code into files in specific directories
I tried file system publish and ftp
I'm using VS2010 and .net 4.0
should i somehow include *.spark ext files to the MSBuild?
See this. You basically have to set .spark files' Build Action to Content.
Here's a macro to do so:
Sub SetSparkBuildAction(ByVal scope As EnvDTE.vsBuildScope, ByVal action As EnvDTE.vsBuildAction) Handles BuildEvents.OnBuildBegin
For Each proj As Project In DTE.Solution.Projects
RecurseSetSparkBuildAction(proj)
Next
End Sub
Sub RecurseSetSparkBuildAction(ByVal item As Object)
If (item.Name.EndsWith(".spark", StringComparison.CurrentCultureIgnoreCase)) Then
item.Properties.Item("BuildAction").Value = 2
End If
For Each childItem As ProjectItem In item.ProjectItems
RecurseSetSparkBuildAction(childItem)
Next
End Sub
To use this macro, open up Macros IDE (Alt+F11), locate EnvironmentEvents in a leftmost treeview and paste this code outside of the "Automatically generated code, do not modify" region.