Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying Form Text and Pasting Clipboard Contents to Excell

Status
Not open for further replies.

DRH192

Programmer
Apr 25, 2005
96
GB
All,

I am having a nightmare with the following piece of code.

Me.Dialog.SetFocus
Me.Dialog.SelStart = 0
Me.Dialog.SelLength = Len(Me.Dialog)
DoCmd.RunCommand acCmdCopy

When it executes the last line (DoCmd.RunCommand acCmdCopy), instead of copying the text select from the control "Dialog" on my form, it copies the object which is selected in the database window! i.e. if tblFiles is selected in the db window it pastes the contents of the table to my excell workbook. If a form is selected in the db window the program fails when attempting to paste to excell.

I thought it may have been because the form was not set to Modal, but this was not the case.

The annoying thing is, I had this working perfectly only yesterday, and now I can't seem to re-trace my steps to see whats changed.

Any help would be gratfully recieved

Cheers
 
I worked around this very annoying problem using the following method.

Dim S As String
S = Me.Dialog

Dim X As Integer

With wks
Range("A1").Activate

For X = 1 To SF_count(S, vbNewLine)
Range("A" & X) = SF_splitLeft(S, vbNewLine)
S = SF_splitRight(S, vbNewLine)
Next X

Range("A1").SELECT
End With


The above loops through the lines in the text I need to publish to excell and wraites each line to the next excell row at column "A"

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top