I try to create a macro for excel which reads the content of a text file, creates a new workbook of it and than uses a specific section inside the created workbook. To be able to get easy access to needed columns, I worked with Workbook.OpenText. But instead of inserting a fix path to my file, i would like to get the path of the file I copied to the clipboard. My Problem is, I don’t know how to get access to the clipboard of windows. I found a tutorial on working with the clipboard here, but i can’t get access to the expected library. I also searched also on my computer for a file called FM20.DLL like explained in this forum but couldn’t find anything.
Here is my code:
Workbooks.OpenText Filename:="C:\path\to.txt", Origin _
:=-535, StartRow:=16, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1 _
), Array(14, 1), Array(58, 1), Array(68, 1)), TrailingMinusNumbers:=True
I just solved the problem on a different way. I don’t use the OpenText method anymore. I used following code to insert from clipboard into my worksheet:
This isn’t the answer of my question, but looks much easier to me as the answer before. It also worked, but i had to import library manually and write a lot more code.
The way i have to access the code is now another. I jump from line to line, get save the line in a variable, delete the whitespace from the string
and create an array with the several values by using
Anyway, thank you for help 😉