Skip to main content

Posts

Showing posts from 2017

Add a user in command line in Windows and Linux

How to add a user via command line in Windows and Linux?

Adding a user whether in Linux or Windows requires the user have rights to create.

In Windows you must be a member of the administrator or other groups who has the rights to create a user.

In Linux you must be a root or either a member of the sudoers depending on what distro you are using.

In Windows to create  a local user in a Windows client operating system such as Windows 7 or Windows 10.

A one liner command can be issued to create a local user, using the command prompt Window at an elevated mode or administrator mode.

At the command prompt type:

Net user  "username" "password" /add

Net user  << this should be type like that it’s part of the command syntax while username and password, can be any data and of course /add is needed meaning the command is adding a user to the system.

Example: net user spiderbond 007-homeSp!dey /add

Command will add a user name called spiderbond and the password is 007-…

Set a graph or shape in Word behind text using VBA

How to set a graph or shape in Word so it stays behind the text using VBA?
In Word the option is to right click an object select wrap text and click the desired options such as behind text, in front of text and other options.
Setting a graph behind the text is quite useful, if you need to display some text that will be displayed together with the graph.
To do this via VBA is plain and simple, a one liner code.
ThisDocument.Shapes("NameOfTheChart").WrapFormat.Type = wdWrapBehind
wdWrapBehind is equal to set "Behind Text".
The one liner VBA code, of course it will apply to any shapes, circle, oval, square or other shapes not just a graph.
Code works on Word 2016, it may or may not word in previous version of  Word. 

Cheers. Till next time!


================================ Free Android Apps:
Click on links below to find out more:
Catholic Rosary Guide  for Android:
https://play.google.com/store/apps/details?id=com.myrosaryapp
http://quickbytesstuff.blogspot.sg/2014/09/how-t…

How to position a graph in word in a specific page?

Positioning a graph in word is necessary to put the graph in a page where the description or other supporting details for the graph will be placed.
But, how to place or put a graph in a specific page in a document?
By default, the graph will be generated in the first page of the document.
To position a graph in any page in the document is to create a bookmark.
If you know exactly where to put the graph, manually create a bookmark by clicking  “Insert” in the ribbon and selecting “Bookmark”.
After clicking “Bookmark” it will ask for a name and create any name to define the bookmark.
Once the bookmark has been named and created, you can call the bookmark via VBA.
Here’s the code to call and select a bookmark:
ActiveDocument.Bookmarks("graph1").Select
graph1 – is the name of the bookmark.
After selecting the bookmark via VBA, call the method to generate the chart.
Like:
'initialize and set graph type
 Set shp = ActiveDocument.Shapes.AddChart(xlXYScatterLines, -18, 80, 480, 3…

Linux list folders recursively

To list all folders on the root directory, type:
  ls -d /*
Sample Output:
/bin     /dev   /smsbackup  /lost+found  /mnt  /proc  /selinux  /tmp /boot    /etc   /lib        /media       /net  /root  /srv      /usr /cgroup  /home  /lib64      /misc        /opt  /sbin  /sys      /var
To list all folders on the current folder, one level depth only; type:
[xxx@mx var]$ ls -d */
Sample Output:
account/  cvs/    games/  local/  lost+found/  opt/       spool/  yp/ cache/    db/     gdm/    lock/  sms/        preserve/  tmp/ crash/    empty/  lib/    log/    nis/         run/       www/

List all folders and sub folders, 2 level depth or 2 level hierarchy; type:
[xxx@mx var]$ ls -d */*/
Sample Output:
cache/abrt-di/        lib/misc/        log/ConsoleKit/      run/portreserve/ cache/cups/           lib/mlocate/     log/cups/            run/rhsm/ cache/fontconfig/     lib/net-snmp/    log/sms/            run/saslauthd/ cache/foomatic/       lib/nfs/         log/gdm/             run/sepermit/ cache…

Word VBA to set x and y chart values

How to set X and Y values in Word VBA chart?

How to set vertical and horizontal values for a Word chart using VBA?

Code below assumes that you already have the necessary code to generate the chart.

This code below will only show how to set the X and Y values for a chart using VBA in a Word document.

Here's the code:

'Set value for Y axis or Vertical value

With cht.Axes(xlValue)

   .MinimumScale = 0
   .MaximumScale = 35
   .MajorUnit = 5
   .MinorUnit = 0

End With


' Set value for X axis or Horizontal value

With cht.Axes(xlCategory)

   .MinimumScale = 0
   .MaximumScale = 25
    .MajorUnit = 5
   .MinorUnit = 0    

End With




Cheers! Till next time.

Kindly help to fill out this survey:(social media effects)
https://1drv.ms/xs/s!AoHcvCpSMSIdjEuJzjCHl4sMh2su
================================ Free Android Apps:
Click on links below to find out more:
Excel Keyboard shortcuts guide https://play.google.com/store/apps/details?id=chrisjoms.myexcelapplicationguide
Linux Android App cheat sheet: https://play…

VBA Word change graph data point width

If you have been playing with the chart in Word or Excel you might encountered that the point on the graph is quite small.
If you need to adjust the data point on Word graph, you have two options do it manually or simply automate it at runtime using a VBA code.
Assuming you have all the necessary parameters that creates the graph via VBA, and you just need to adjust the data point you can use the code below, the code below was tested using Word 2016. It may not apply to older versions but I think logic should stay the same.
cht.SeriesCollection(1).Format.Line.Weight = 9.75
To do it manually, click on the data point and right click on it and select “Format Data Point”, click the bucket icon and change the width value.

Here’s the screen shot using Word 2016:

For the sake of completeness, the code will be something like this:
Dim shp As Shape Dim cht As Chart  
Set shp = ActiveDocument.Shapes.AddChart(xlXYScatterLines)   Set cht = shp.Chart
Dim wb As Excel.Workbook Dim ws As Excel.Worksh…

How to rename a chart in Word 2016

Do you want to check what’s the name of the chart in Word 2016?
Or you just want to rename the chart in Word 2016 to a name, that the chart represents?
Word 2016 default chart name is in sequence, like Chart1, Chart2, Chart3 and it follows this pattern depending on how may charts you have at your document.

If you have multiple charts in a word document, and you want the chart name it to something meaningful or what the chart itself is all about; it’s quite easy and straight forward to rename a chart, but the way to rename it is not conventional as the previous way of doing it in other version of office.
You can rename the chart via VBA code or using the GUI in Word itself.
To rename or check the name of the chart in Word 2016 or O365.
Click on the chart:

After clicking the chart, the "Chart Tools" will open at the Ribbon.
Click the "Chart Tools"  at the ribbon. Click on the "Format" tab.
Under Format tab, click on "Selection Pane", this will op…

Access denied renaming shared folder

If you are working in a shared active directory environment and has a shared folder that needs to be renamed once in a while.
But every time you want to rename there is always a user who is using the folder and therefore, renaming the folder is denied.
How to rename the folder when the shared folder is always in use?
Automation will come for the rescue in such a scenario.
How to automate renaming the folder?
Task scheduler and a simple batch file can do the task and a life saver.
Here's how to do it:
Of course, disconnect all the open files. Users should shutdown their computers when they went out of the office,
If they don't shutdown, force their disconnection by using the command below:
openfiles /disconnect /o read/write openfiles /disconnect /o no access
Then, rename the folder with the ren or rename command of course.
Syntax is the good old fashioned source folder or path and the new folder name.
If the batch file will be run directly on the server, then the drive letter w…

Use tar command to backup in Linux

tar or tape archive is a basic tool that every Linux user should know.

Its syntax is quite different from the traditional copy or move command.

Since tar works from a 'current working directory' perspective.

Traditional syntax for copy or move is source then the destination.

In tar, the syntax is the filename or the path where the backup will be save and the source or the folder to be backed up or archived.

Typing: man tar (at the terminal shows the following)

tar -cf archive.tar foo bar
# Create archive.tar from files foo and bar.

Basically, it's like the destination where the file will be saved and the source or the files that will be archived.

Here's a simple bash script that will append the time and date the tar file was executed to the filename of the tar file.

If the bash script is automated via cron, the filename of the tar file will include the date and time the cron executes the script.


#script begins

#!/bin/bash
NOW=$(date +%Y%m%d%H%M)
echo $NOW
tar -Pczvf   /mnt/o…

PowerShell get folder capacity

Get the folder capacity using PowerShell via the old-school method.
Old-school since we will utilize the native “dir” command, just like the good old days of DOS.
PowerShell dir command output is not the same with the native windows system32 dir command line just like in DOS system.
The output will be in bytes since it is from the command line but of course, if you are command line junkie it will be easy to read even if the capacity is written in bytes.
First, fire up notepad write the dir command plus the full folder path of the specified folder in which you like to monitor or want to know the capacity.
 dir “c:\users\dmusic\music folder 001”
The path is enclosed in quotes since the folder has spaces and save the notepad as a batch file with “.bat” extension.
Open PowerShell command line window or PowerShell ISE and type the following command:
#change the path to where the batch file was saved
$folder_base_cap = d:\read_folder_cap.bat 
$ folder_base_cap | Select-String "bytes&qu…