Last active
September 14, 2017 07:55
-
-
Save bmccormack/2489a624aaa050e952ef to your computer and use it in GitHub Desktop.
Python script to read from standard input to fake multi-line VBA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
& 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.