Skip to content

Instantly share code, notes, and snippets.

@bmccormack
Last active September 14, 2017 07:55
Show Gist options
  • Save bmccormack/2489a624aaa050e952ef to your computer and use it in GitHub Desktop.
Save bmccormack/2489a624aaa050e952ef to your computer and use it in GitHub Desktop.
Python script to read from standard input to fake multi-line VBA
import fileinput
print 'Dim str As String'
print 'str = ""'
to_print = []
for line in fileinput.input():
line = line.strip('\n')
line_vba = 'str = str & "%s"' % line.replace('"','""')
to_print.append(line_vba)
all_lines = " & vbCrLf\n".join(to_print)
print all_lines
@antonyraja1507
Copy link

& vbCrLf & _ How to mention this VBA script to replace() method in python?

elif ''& vbCrLf & _'' in line:
file2.write(line.replace("'& vbCrLf & _'", "\r\n")) - is this correct? Not working for me please help me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment