Skip to content

Instantly share code, notes, and snippets.

View rdapaz's full-sized avatar

ricdeez rdapaz

View GitHub Profile
@rdapaz
rdapaz / JoinCells.vb
Created June 21, 2018 09:45 — forked from ricdeez/JoinCells.vb
VBA: Join Cells on a Spreadsheet
Public Sub JoinCells()
Dim xls As Excel.Worksheet
Dim cell As Excel.Range
Dim destn_rge As Excel.Range
Dim combined As String
Dim i As Long
i = 0
Set destn_rge = Nothing
@rdapaz
rdapaz / temp.py
Created May 21, 2018 17:29
Getting column name from column number in Excel
def column_name(iVal):
retVal = None
if iVal <= 26:
retVal = chr(64+iVal)
else:
m = int(iVal/26)
n = iVal - m*26
if n==0:
m = m-1
n = 26
@rdapaz
rdapaz / temp.py
Created May 21, 2018 16:43
Using PostgreSQL from Python
import psycopg2
conn = psycopg2.connect("dbname='timesheets' user=postgres")
if True:
cur = conn.cursor()
sql = """
CREATE TABLE IF NOT EXISTS \"public\".\"ts\" (
id serial primary key,
dt date,
project text,
@rdapaz
rdapaz / temp.py
Created May 21, 2018 16:35
Get a path to the folder where the script is executing from
current_path = os.path.dirname(sys.argv[0])
os.chdir(current_path)
ROOT = r'.'
@rdapaz
rdapaz / MSProject.py
Created April 12, 2018 03:30 — forked from zlorb/MSProject.py
MSProject - Python
import sys, time, datetime
from copy import copy, deepcopy
from collections import OrderedDict
import string
import math
import win32com.client
import traceback
# Sample code for accessing MSProject
# 2014 (C) Zohar Lorberbaum
@rdapaz
rdapaz / MSProjectUseRelativeDates.txt
Created April 12, 2018 03:26
MSProject Use Relative Dates
In a Custom Text Field, create a formula such as:
Start:
"T" & IIf(ProjDateDiff(#16/04/2018#,[Start])>=0,"+","") & ProjDateDiff(#16/04/2018#,[Start])/480 & "d"
Finish:
"T" & IIf(ProjDateDiff(#16/04/2018#,[Finish])>=0,"+","") & ProjDateDiff(#16/04/2018#,[Finish])/480 & "d"
@rdapaz
rdapaz / win32com.client.py
Last active November 19, 2024 06:07
Fix for module win32com.gen_py has no attribute 'CLSIDToPackageMap'
# If errors are found, do this
# clear contents of C:\Users\<username>\AppData\Local\Temp\gen_py
# that should fix it, to test it type
import win32com.client
app = win32com.client.gencache.EnsureDispatch('Word.Application')
app.Visible = True
@rdapaz
rdapaz / GlossaryMaker.vbs
Created March 9, 2018 08:46
Creates a Table of Glossary Terms in Word
Sub GlossaryMaker()
'
' GlossaryMaker Macro
'
'=========================
'Macro created 2008 by Lene Fredborg, DocTools - www.thedoctools.com
'THIS MACRO IS COPYRIGHT. YOU ARE WELCOME TO USE THE MACRO BUT YOU MUST KEEP THE LINE ABOVE.
'YOU ARE NOT ALLOWED TO PUBLISH THE MACRO AS YOUR OWN, IN WHOLE OR IN PART.
'=========================
'The macro creates a new document,
@rdapaz
rdapaz / mso_wd_UpdateTableCells.bas
Created August 28, 2017 09:36
Update Cells in a Table with the Same Value
Public Sub Test()
Dim c As Word.cell
Set c = Selection.Tables(1).cell(1, 1)
For Each c In Selection.Cells
c.Range.Text = "$NIL"
Next c
@rdapaz
rdapaz / dymo_multi_label_print.py
Created August 15, 2017 03:40
Python Script to Print to Dymo Labeller
#Testcoding: utf-8
import time
import win32com
import win32com.client
labels_to_print = """
Label 1
Label 2
Label 3
""".splitlines()