20 September 2018

MS Word - Another use for Ctrl+z

Quite a number of articles giving tips and tricks on MS Word advice turning off automatic formatting when users get frustrated and want to stop MS Word from changing certain things that they type, for example, three dashes turning into a horizontal line, or automatically converting to the copyright symbol after typing (c).

There's a simpler solution without the need to go through all the hassle of turning automatic formatting off.

Just undo the typing, or Ctrl+z (the keyboard shortcut).

And next time if you need the horizontal line fast, you can still do it the three dashes way.




15 September 2018

Filler Text for MS Word

Have you come across instances when you need filler text for your MS Word documents, especially when creating templates?

Instead of going to the browser, find a lorem ipsum generator, generate the text, copy, and then going back to MS Word and pasting it, you can do it in just one step. Type "=lorem(p,l)" in your document, where "p" == the number of paragraphs and "l" == the number of lines to generate.

And hit Enter.

Viola! It's like magic.


13 September 2018

MS Excel VBA - Copy hidden Excel worksheet contents to new workbook

Was trying to copy the contents of a hidden worksheet in an Excel to a totally new workbook and edit it via VBA and faced several issues.

     - One can't copy contents from a hidden worksheet. The worksheet must be visible in order for it to be copied.
     - After making it visible, and copying it, there were problems making it hidden again as the current active workbook is the new one instead of the original one.

So the solution is to
   1) Make the hidden worksheet visible
   2) Activate the original workbook
   3) Hide the worksheet
   4) Activate the new workbook with the copied sheet

Below's the code, hopefully can help someone who's facing the same problem out there.

Sub copyHidden()
  'Make hidden sheet visible for copying to new workbook
  Sheets("hiddenSheet").Visible = True
  Sheets("hiddenSheet").Copy

  'activate the original workbook to hide the sheet again
  newbook = Workbooks.Count
  Workbooks.Item(newbook - 1).Activate
  Worksheets("hiddenSheet").Visible = False

  'activate the new workbook with the copied sheet
  Workbooks(newbook).Activate
  ActiveSheet.Name = "copiedSheet"

  'the rest of your code here

End Sub