VBA to export "Clipboard" data to text file

M

mario

Can you please help me with the following:

1. VBA code to export the MS Office Clipboard data to text file. I can paste
the clipboard data into text file, then import into MS Access Table. But I
would like to automate the process. The clipboard data comes from a screen
shot of AS400.

2. VBA to insert a column in all the tables in a given MS Access Database
".mdb". The newly inserted column will be LEFT("Student_Name", 7) and name of
the new column will be "My_Column"

3. VBA to create a new table by exporting the results of an existing querry.

Thanks in advance for all your help.
 
A

Arvin Meyer [MVP]

mario said:
Can you please help me with the following:

1. VBA code to export the MS Office Clipboard data to text file. I can
paste
the clipboard data into text file, then import into MS Access Table. But I
would like to automate the process. The clipboard data comes from a screen
shot of AS400.

Thios may help:
http://www.mvps.org/access/api/api0049.htm
2. VBA to insert a column in all the tables in a given MS Access Database
".mdb". The newly inserted column will be LEFT("Student_Name", 7) and name
of
the new column will be "My_Column"

You don't really want to do this because it violates database Normalization
rules. No data should ever be dependent on anything but the key (not the
other way around). That said, here's how you can totally screw up your
database (aircode):

Sub AddField()

Dim db As DAO.Database

Set db = OpenDatabase("Your database path.mdb")

db.Execute "ALTER TABLE TableName " _
& "ADD COLUMN My_Column TEXT, 7;"

db.Close

End Sub

Then a query

INSERT INTO MyTable [IN Your database path.mdb] My_Column
SELECT LEFT([Student_Name], 7)
FROM [SDtudent_Name];
3. VBA to create a new table by exporting the results of an existing
querry.

Just use a Make-Table query, which you can call in code (like question 1)
 
M

mario

Thank so much for answering my post.

The link you had mentioned talks about VBA to copy some data into clipboard.
But I am interested in saving the clipboard memory contents into a notepad.

Thanks and appreciate your assistnace.

Mario


Arvin Meyer said:
mario said:
Can you please help me with the following:

1. VBA code to export the MS Office Clipboard data to text file. I can
paste
the clipboard data into text file, then import into MS Access Table. But I
would like to automate the process. The clipboard data comes from a screen
shot of AS400.

Thios may help:
http://www.mvps.org/access/api/api0049.htm
2. VBA to insert a column in all the tables in a given MS Access Database
".mdb". The newly inserted column will be LEFT("Student_Name", 7) and name
of
the new column will be "My_Column"

You don't really want to do this because it violates database Normalization
rules. No data should ever be dependent on anything but the key (not the
other way around). That said, here's how you can totally screw up your
database (aircode):

Sub AddField()

Dim db As DAO.Database

Set db = OpenDatabase("Your database path.mdb")

db.Execute "ALTER TABLE TableName " _
& "ADD COLUMN My_Column TEXT, 7;"

db.Close

End Sub

Then a query

INSERT INTO MyTable [IN Your database path.mdb] My_Column
SELECT LEFT([Student_Name], 7)
FROM [SDtudent_Name];
3. VBA to create a new table by exporting the results of an existing
querry.

Just use a Make-Table query, which you can call in code (like question 1)
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 
A

Arvin Meyer [MVP]

Here's some code to paste into a textbox using a the double-click event.
First put this in your standard module:

Public Function PasteHere()
DoCmd.RunCommand acCmdPaste
End Function

Then in the Double-Click property of any textbox that you want to paste the
clipboard contents to add:

=PasteHere()
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

mario said:
Thank so much for answering my post.

The link you had mentioned talks about VBA to copy some data into
clipboard.
But I am interested in saving the clipboard memory contents into a
notepad.

Thanks and appreciate your assistnace.

Mario


Arvin Meyer said:
mario said:
Can you please help me with the following:

1. VBA code to export the MS Office Clipboard data to text file. I can
paste
the clipboard data into text file, then import into MS Access Table.
But I
would like to automate the process. The clipboard data comes from a
screen
shot of AS400.

Thios may help:
http://www.mvps.org/access/api/api0049.htm
2. VBA to insert a column in all the tables in a given MS Access
Database
".mdb". The newly inserted column will be LEFT("Student_Name", 7) and
name
of
the new column will be "My_Column"

You don't really want to do this because it violates database
Normalization
rules. No data should ever be dependent on anything but the key (not the
other way around). That said, here's how you can totally screw up your
database (aircode):

Sub AddField()

Dim db As DAO.Database

Set db = OpenDatabase("Your database path.mdb")

db.Execute "ALTER TABLE TableName " _
& "ADD COLUMN My_Column TEXT, 7;"

db.Close

End Sub

Then a query

INSERT INTO MyTable [IN Your database path.mdb] My_Column
SELECT LEFT([Student_Name], 7)
FROM [SDtudent_Name];
3. VBA to create a new table by exporting the results of an existing
querry.

Just use a Make-Table query, which you can call in code (like question 1)
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 
M

mario

Thanks again Arvin.

I am not good in explaining. How do I do this:
1. By clicking a command button, in access form.
2. I want to give a choice of drop down list for the name of text file to be
created in the current directory
3. Create a new text file with name chosen in step 2, and dump all the
contents in clipboard memory into the text file.
4. Ideally I would like to create a table from the text file.

If I can accomplish upto step 3, I can accomplish step 4. Please help me in
step 3 in particular.

Thanks in advance.

Arvin Meyer said:
Here's some code to paste into a textbox using a the double-click event.
First put this in your standard module:

Public Function PasteHere()
DoCmd.RunCommand acCmdPaste
End Function

Then in the Double-Click property of any textbox that you want to paste the
clipboard contents to add:

=PasteHere()
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

mario said:
Thank so much for answering my post.

The link you had mentioned talks about VBA to copy some data into
clipboard.
But I am interested in saving the clipboard memory contents into a
notepad.

Thanks and appreciate your assistnace.

Mario


Arvin Meyer said:
Can you please help me with the following:

1. VBA code to export the MS Office Clipboard data to text file. I can
paste
the clipboard data into text file, then import into MS Access Table.
But I
would like to automate the process. The clipboard data comes from a
screen
shot of AS400.

Thios may help:
http://www.mvps.org/access/api/api0049.htm

2. VBA to insert a column in all the tables in a given MS Access
Database
".mdb". The newly inserted column will be LEFT("Student_Name", 7) and
name
of
the new column will be "My_Column"

You don't really want to do this because it violates database
Normalization
rules. No data should ever be dependent on anything but the key (not the
other way around). That said, here's how you can totally screw up your
database (aircode):

Sub AddField()

Dim db As DAO.Database

Set db = OpenDatabase("Your database path.mdb")

db.Execute "ALTER TABLE TableName " _
& "ADD COLUMN My_Column TEXT, 7;"

db.Close

End Sub

Then a query

INSERT INTO MyTable [IN Your database path.mdb] My_Column
SELECT LEFT([Student_Name], 7)
FROM [SDtudent_Name];

3. VBA to create a new table by exporting the results of an existing
querry.

Just use a Make-Table query, which you can call in code (like question 1)
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 
A

Arvin Meyer [MVP]

Creating a file has nothing at all to do with adding text from the clipboard
to a field in an Access table. Neither does choosing a file name from a
dropdown list. You'll need to try again to explain what you are trying to
accomplish. Try to be specific with the types of data that you have and
exactly what you want to do with it (i.e. store in a separate text file, and
name that file, or store the text in an Access field in a table that has
been predefined.) If you can be specific with what the data is, and how you
plan to use it after it is stored, I can come up with a methodology for you.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


mario said:
Thanks again Arvin.

I am not good in explaining. How do I do this:
1. By clicking a command button, in access form.
2. I want to give a choice of drop down list for the name of text file to
be
created in the current directory
3. Create a new text file with name chosen in step 2, and dump all the
contents in clipboard memory into the text file.
4. Ideally I would like to create a table from the text file.

If I can accomplish upto step 3, I can accomplish step 4. Please help me
in
step 3 in particular.

Thanks in advance.

Arvin Meyer said:
Here's some code to paste into a textbox using a the double-click event.
First put this in your standard module:

Public Function PasteHere()
DoCmd.RunCommand acCmdPaste
End Function

Then in the Double-Click property of any textbox that you want to paste
the
clipboard contents to add:

=PasteHere()
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

mario said:
Thank so much for answering my post.

The link you had mentioned talks about VBA to copy some data into
clipboard.
But I am interested in saving the clipboard memory contents into a
notepad.

Thanks and appreciate your assistnace.

Mario


:

Can you please help me with the following:

1. VBA code to export the MS Office Clipboard data to text file. I
can
paste
the clipboard data into text file, then import into MS Access Table.
But I
would like to automate the process. The clipboard data comes from a
screen
shot of AS400.

Thios may help:
http://www.mvps.org/access/api/api0049.htm

2. VBA to insert a column in all the tables in a given MS Access
Database
".mdb". The newly inserted column will be LEFT("Student_Name", 7)
and
name
of
the new column will be "My_Column"

You don't really want to do this because it violates database
Normalization
rules. No data should ever be dependent on anything but the key (not
the
other way around). That said, here's how you can totally screw up your
database (aircode):

Sub AddField()

Dim db As DAO.Database

Set db = OpenDatabase("Your database path.mdb")

db.Execute "ALTER TABLE TableName " _
& "ADD COLUMN My_Column TEXT, 7;"

db.Close

End Sub

Then a query

INSERT INTO MyTable [IN Your database path.mdb] My_Column
SELECT LEFT([Student_Name], 7)
FROM [SDtudent_Name];

3. VBA to create a new table by exporting the results of an existing
querry.

Just use a Make-Table query, which you can call in code (like question
1)
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 
L

Lord Kelvan

create a new module and paste this into it

Sub writetofile()

Dim theclipboard
theclipboard =
CreateObject("htmlfile").ParentWindow.ClipboardData.Getdata("text")

Open "yournewfile.txt" For Output As #1
Print #1, theclipboard
Close #1
End Sub

note this sub will replace any existing file by the name of
yournewfile.txt with the clipboard data in it

hope this helps

Regards
Kelvan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top