windows,osx,vba,excel-vba,cross-platform , VBA - username in both Windows and OSX

VBA - username in both Windows and OSX


Tag: windows,osx,vba,excel-vba,cross-platform

I'm writing VBA code to gather input from several xlsx files and combine them into a single master sheet. Since the users of this sheet are mixed Windows and OSX users, my code needs to be universal across both platforms.

One of the things I'd like to achieve is to determine the user's username. This can be done using environ("username") on Windows and MacScript on OSX. However, below code cannot be compiled on Mac, since it doesn't know environ().

OS_IS_MAC = Application.OperatingSystem Like "*Mac*"
   sMyScript = "set userName to short user name of (system info)" & vbNewLine & "return userName"
   USERNAME = MacScript(sMyScript)


   USERNAME = Environ("UserName")

End If

How can I get around this?


Use conditional compilation:

#If Mac Then
   sMyScript = "set userName to short user name of (system info)" & vbNewLine & "return userName"
   USERNAME = MacScript(sMyScript)
   USERNAME = Environ("UserName")
#End If


Change the “about this” window on mac app

On Macs, there's a default menu at the top for basic application handling functions: I've made an application using Java for my Grade 10 final project, (and I'm quite convinced that it's better than Microsoft Paint) and I decided to package it. Using Eclipse, I exported it as a Mac...

Error when adding VideosLibrary capability in app's manifest file

According to the documentation, capabilities must be declared when an application requires programmatic access to certain user resources such as the Videos Library. This page of the documentation also states: All Windows Phone capabilities are not available for apps being developed specifically for Windows 10 Insider Preview. I am building...

How to get NSTableView to use a custom cell view mixed with preset cell views?

I have a NSTableView configured in Interface Builder which uses several default cell views. However the first column's cell view needs to be created from a custom class. How do I implement NSTableViewDataSource method tableView.viewForTableColumn() so that it creates the default cell views for the remaining columns? Here's my method...

Eclipse CDT - No Console Output on OSX

New to the C++ world and wanted to fiddle around using Eclipse's IDE for C/C++ called CDT. I am on OSX 10.10.2 using eclipse-cpp-luna-SR2-macosx-cocoa-x86_64. Sadly this simple example is not printing anything in the eclipse terminal. #include <iostream> using namespace std; int main() { cout << "Hello World" << endl;...

Call to implicitly-deleted copy constructor in LLVM(Porting code from windows to mac)

We are in the process of porting some c++ code from windows to mac and are having issues compiling it with LLVM 6.1 using c++11. We are encountering errors all over the place of "Call to implicitly-deleted copy contructor" Some of these errors are popping up in our code. for...

OSX tmux configuration session open file in vim automatically

So I have tmux and vim running in iterm2 on OSX. I have a tmux.conf file that sources a session in ~/.tmux/ called 'left'. I have successfully loaded this session with three panes. Two panes in a left column and a single pane on the right. I have also managed...

Unable to edit netbeans.conf

I am trying to modify 'netbeans.conf' located at following path: C:\Program Files\NetBeans 8.0.2\etc When i modify the file; add -J-Dfile.encoding=UTF-8 In Notepad, it is not allowing me to save the original file. In Notepad++, it says 'please echeck if this file is opened in another program'. Netbeans is installed in...

Apache - finding configuration file path

I have to migrate another apache instance from 2.2 to 2.4 but I have one problem. In Apache monitor I see multiple services running but I don't really know where apache .conf files are stored. In previous migrations from 2.2 to 2.4 I had them somewhere within conf folder. Apache...

Application is missing required files

Pic of Error: Cannot Download the Application. The Application is missing required Files. Contact Application Vendor For Assistance. So I'm building a windows form application using SharpDevelop 5.2 and I'm trying to make a standalone/version someone else would be able to use on another machine. In sharpdevelop (and visual...

I cannot use the msg command in cmd (or batch for that matter). How can I fix this?

While in cmd or making a batch file, I cannot use the command msg. When I try to use it, it returns the error msg is not recognized as an internal or external command, operable program or batch file." I'm pretty sure the error is that im missing a msg.exe...

How to uninstall all python versions and use the default system version of OS X 10.10?

I'm looking for a way to cleanly uninstall all versions of python on OS X 10.10 except the default version that followed with the Mac. How do I proceed? Currently I've some weird behaviour. When typing which -a python I get the following output: /Users/harisfawad/anaconda/bin/python /Library/Frameworks/Python.framework/Versions/2.7/bin/python /usr/local/bin/python /usr/bin/python Why doesn't...

Automate MySQL backup @localhost with mysqldump in Windows 8

I'm trying to set up a task in Windows 8 to automate my localhost db dump. I've created the task to run daily with the following command line: C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqldump.exe and parameters: --user=root --password=donttellya --result-file=dumped.sql mydb It works but doesn't terminate (running in the tasks list). Also, I'd...

Increment Serial Number using EXIF

I am using ExifTool to change the camera body serial number to be a unique serial number for each image in a group of images numbering several hundred. The camera body serial number is being used as a second place, in addition to where the serial number for the image...

How to send Ctrl+S through SendKeys.Send() method to save a file(save as dialog)

I need to save a file which is in an External application using SendKeys.Send() method. The keys needed to be sent are Ctrl+S. I wrote the below code, but its not working: SendKeys.SendWait("^%s?"); // to get the Save As dialog Thread.Sleep(5000); SetForegroundWindow(FindWindow(null, "Save As")); Thread.Sleep(5000); SendKeys.SendWait("xyz"); // Sending FileName ...

sys.argv in a windows environment

I'm attempting to learn python using the book 'a byte of python'. The code: import sys print('the command line arguments are:') for i in sys.argv: print(i) print('\n\nThe PYTHONPATH is', sys.path, '\n') outputs: the command line arguments are: C:/Users/user/PycharmProjects/helloWorld/ The PYTHONPATH is ['C:\\Users\\user\\PycharmProjects\\helloWorld', 'C:\\Users\\user\\PycharmProjects\\helloWorld', 'C:\\Python34\\', 'C:\\Python34\\DLLs', 'C:\\Python34\\lib', 'C:\\Python34', 'C:\\Python34\\lib\\site-packages']...

Programmatically close Windows console application c++

I need my windows console application to be run only in one instance (i.e. Only one instance of the application can be run at a time). Here's what I have: int _tmain(int argc, _TCHAR* argv[]) { PCTSTR Name = TEXT("AnyName"); HANDLE h = CreateMutex(NULL, FALSE, Name); if (GetLastError() == ERROR_ALREADY_EXISTS)...

Run Boot2Docker from bash

I have installed Boot2Docker on my Mac. By clicking on the app icon, a terminal window opens with some bash script running to prepare the docker vm and then you're good to go. My problem is, I want to write a bash script to run the Boot2Docker vm and then...

Crash when processing `__Atom` class object in Objective C (using Objective C runtime )

Hi I'm using this answer to get list of class to automatically build some structure. My code looks like that: NSMutableDictionary *result = [NSMutableDictionary dictionaryWithCapacity: 32]; Class* classes = NULL; int numClasses = objc_getClassList(NULL, 0); if (numClasses > 0 ) { classes = (Class*)malloc(sizeof(Class) * numClasses); numClasses = objc_getClassList(classes, numClasses);...

Override .gitattributes text=auto in Windows

This is pretty unintuitive: C:\python-tdl\examples\termbox>git config core.autocrlf false C:\python-tdl\examples\termbox>git commit warning: LF will be replaced by CRLF in examples/termbox/ The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in examples/termbox/ The file will have its original line endings in...

pcap_dispatch() always returns 0 on Mac OSX for wifi interface

I have few devices connected to wifi router, but pcap_dispatch() always returns 0 for wifi interface while live capturing on Mac OS X. The same code captures response in case of wired interface. Please clarify if I have missed any flag here.

Why doesn't “go get…” work while “go get…” OK?

I try to use go get to install pool according to, but can't success: C:\Users\xiaona\Documents\GitHub> go get -v Fetching https fetch failed. Fetching import "": http/https fetch: Get l.v2?go-get=1: dial tcp ConnectEx tcp: A connection attempt failed because the connected party did not...

ffmpeg: wmv files generated on Mac can't be played in Windows

On Mac OS X 10.6.8, I converted a animated gif to a video file in wmv (a requested file format) by using ffmpeg -i File.gif -s 400x400 NewFile.wmv The video file played fine using VLC on Mac. The file can't be played on a Windows 7 machine using the Windows...

How to get CPU utilization in % in terminal (mac)

Ive seen the same question asked on linux and windows but not mac (terminal). Can anyone tell me how to get the current processor utilization in %, so an example output would be 40%. Thanks

Should I use different WSAOVERLAPPED struct for WSASend and WSARecv?

I'm developing a server-client application using WinSock. Does using the same WSAOVERLAPPED with both WSASend and WSARecv works well? Should I use different WSAOVERLAPPED struct for WSASend and WSARecv?...

Why does Windows Server 2008 think Italy should be in W. European Time?

Why does MS Windows (specifically server 2008 here) consider Italy to be in W. European Time when (I think) it should be in Central European Time according to every other source I can find? TZUtil /g gives: W. Europe Standard Time The control panel shows: (UTC+01:00) Amsterdam, Berlin, Bern, Rome,...

String parsing with batch scripting

I have a file called pictures.xml and it contains some pictures information like: <ResourcePicture Name="a.jpg"> <GeneratedPicture Name="b.jpg"/> <GeneratedPicture Name="c.jpg"/> </ResourcePicture> <ResourcePicture Name="z1.jpg"> <GeneratedPicture Name="z2.jpg"/> <GeneratedPicture Name="z3.jpg"/> <GeneratedPicture Name="z4.jpg"/> </ResourcePicture> What I want do do is to get each line in for loop and print the names of the pictures. Sample...

Display django runserver output from Vagrant guest VM in host Mac notifications?

I can think of many ways to skin this cat, and Googling hasn't shown an elegant solution either. Does anyone have an easy / elegant way to forward the output from Django's runserver command in a terminal connected to a guest Vagrant VM to the host to display to Mac's...

How do you work with views in MainMenu.xib?

I'm coming over from iOS development and I can't figure out this basic thing: if I open MainMenu.xib in Interface Builder and I drag a button onto the main window's view, what class should I connect that button's action to -- the App Delegate? If I want to add a...

Suppressing system command called from awk script

I am currently running this script in Windows 7. So, I have a program that is meant to color-code output from another command (mkmk) and tally up varying numbers of errors and other notable stats, etc. So right now, it starts as a batch file which Turns off echo Sets...

How to display Apple San Francisco's numbers mono-spaced rather than proportionally?

I've recently installed El Capitan on OSX, which comes with the new San Franciso font as system font. The apple presentation here (Bit of an overview here: states that, by default, numbers are displayed proportionally. They do allow to switch to displaying them mono-spaced (at least in their...

Parsing the text file line-by-line using batch script (batch file)

So, I am programming in the batch script and I came across this issue. The following code will take yourwords.txt file and parse it. The existedWord variable will have the last word of the text file. So, everytime when I run this program it will only compare the user's input...

Login with Facebook option trigger suggest to download an app

Yesterday I logged in to Airbnb with my Facebook account on my OSX. Shortly later I got a notification both on my iPhone and computer saying "Airbnb is available to install on your iPhone" My question is, does anyone here know how this was done? Is this a feature available...

Run server in cmd in Windows

I created a simple client server codes in PHP and I run it through Wamp server localhost in browser. It works but when I run it in cmd, the output looks like this : c:\wamp\www\Converter>php testserver.php PHP Fatal error: Call to undefined function socket_create() in C:\wamp\www\Converter\testserver.php on line 15 PHP...

Java read bytes from Socket on Linux

I'm trying to send a file from my Windows machine to my Raspberry-Pi 2, and I have a client and a server. The client should be able to send a zip file over the network to my server on my linux machine. I know my client and server work on...

Read plist inside ~/Library/Preferences/

I'm trying to access in ~/Library/Preferences/ but my code doesn't work. NSString *resPath = @"~/Library/Preferences/"; NSError *error = nil; NSArray *filenames = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:resPath error:&error]; if (!error) { for (NSString * filename in filenames) { NSLog(@"%@", filename); } } Maybe I should ask for some permission.. Any idea?...

How to execute four queries once and then check success or failure?,windows,visual-studio-2010,ms-access
I need to execute four queries and then if there is success must return true otherwise false. The queries affect the database but the function returns false Private Function save_to_data() Dim success As Boolean = False Dim conn As OleDbConnection = GetDbConnection() Dim total_due As Decimal = sanitize(txt_total_due.Text) Dim amount_paid...

Execute a batch file before executing in a shortcut (.lnk)

I have multiple versions of a program called Siemens NX. NX uses environmental variables for configuration. I need NX 10.0 to use a different set of environmental variables than my NX 7.5 which uses the system environmental variables. Therefore, I have written a batch file that setups the environmental variables...

Capitalize all files in a directory using Bash

I have a directory called "Theme_1" and I want to capitalize all the filenames starting with "theme". The first letter of every file name is lowercase and I want it to be upcase. I've tried this but all the letters in the filename are upcase, which is not what I...

Recording the time of the start of a screen touch in PsychoPy on Windows

I'm helping to implement an experiment using PsychoPy on a Windows 8 tablet. It doesn't seem to be possible to get direct access to touch events through either PsychoPy, or the pyglet or PyGame interfaces. Most other sources I've found have referred to using mouse move events in place of...

How to set the classpath in Windows Command Line correctly

I have made many attempts to enter a command to run a JAR file correctly from the terminal, and I am 100% sure that all the JAR files and such are in the given paths, but I keep getting a ClassDefNotFoundException. Does it have anything to do with the way...

Mac OSX - Allow for user input in shell script via GUI or Prompt

first time post so please let me know how I could improve.. I created a shell script which requires a person to input their name and then generates a report. The script works as needed when chmod'd into an executable script and run from terminal. But, I would like to...

Use Unix Executable File to Run Shell Script and MPKG File

I have 2 shell scripts and 2 mpkg installer, I am trying to use an unix excitable file to run them all. here is the script I have, but it always has error message "No such file or directory" ? #!/bin/sh # Find the absolute script current path path=$( cd...

bat file script to check if string contains other string

I need to write a batch file that will check if a variable contains specific value. I tried to do the following: If "%%a"=="%%a:%pattern%" ( echo Yes ) else ( echo No ) input example: %%a="bob binson" %patern%="binson" I never get Yes printed! can anyone please tell what i missed...

String manipulation with batch scripting

I need to save the variable in %%c temporarily which comes from a for loop. But when I try to do that, the content changes unexpectedly. Some space characters appear at the end of the string. The content of %%c is a.jpg by the way. echo %%ca REM prints a.jpga...

What is the max length of a share path in windows?

As I read in the MSDN site, for example, the maximum path on drive D is "D:\some 256-character path string" where "" represents the invisible terminating null character for the current system codepage. But when I was created a share with a long path (more than 100 symbols) they trim...

ASP.NET vnext overriding status code set in controller. Is this a bug?

I'm building a simple WebApi in vnext on a Mac. I've followed the example set in this tutorial but I'm having a problem where the response codes I set in my controller methods are being overridden Take this method in my CrudController: [HttpPost] public void Post([FromBody]CrudObject crudObject) { var...

Would using Vagrant be overkill? [on hold]

I'm a developer-hobbyist running Windows 8.1 on a Yoga 2 Pro. I mostly do Python/Django work but I think I'm gonna pick up Ruby soon. The thing is, Windows always seems to be the limiting factor for any project I want to pick up. Last time I tried to install...

UAC error while installing Xampp 1.8.35 on windows 8

I am trying to install xampp but before installation it gives me the following error: I have disabled UAC and it gives me this error.When I press ok and install the thing anyway it still won't let start apache and my sql up. Also installation was done in Program file...

Listing directories by content size using C# [closed]

I'm trying to list all folders of my c drive excluding the document folder which i do not seem to have access to. This first seemed rather simple to me but i found myself still struggling with it despite the seemingly rich .net library. I can't post any code as...

Batch - Comparing two txt files

I have some difficulties comparing two txt files with batch. I used the "findstr" function with many option matchings but none works (for example FINDSTR /I /V /B /G:file1.txt file2.txt). I have a first txt file as following: File1.txt Object 1 Argument 50 Object 2 Argument 10 Object 3 Argument...