Link to home
Start Free TrialLog in
Avatar of etech0
etech0Flag for United States of America

asked on

dataobject in excel 2010 vba

Hi! With some help from the experts I compiled the following macro.

Sub getfname()
Dim cltxt As dataobject
Set cltxt = New dataobject

Dim txt As String
txt = Right(ActiveDocument.Path, Len(ActiveDocument.Path) - InStrRev(ActiveDocument.Path, "\")) & " - " & Left(ActiveDocument.name, Len(ActiveDocument.name) - InStrRev(ActiveDocument.name, "."))
cltxt.SetText (txt)
cltxt.PutInClipboard
End Sub

It works fine in Excel 2007, but in 2010 I get the error User-type defined not defined

Can anyone help?
SOLUTION
Avatar of redmondb
redmondb
Flag of Afghanistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Slow fingers :)
Avatar of etech0

ASKER

Do you know which reference it is?
Alternatively, maybe you know how to pass a variable to the clipboard in vba...
Nice to be (slightly) ahead of you, for once!
tools, references, Microsoft forms 2.0 Object Library  - at least on my machine
Avatar of etech0

ASKER

Thanks to both of you.
However, I don't have "Microsoft Forms 2.0 Object Library" in the list of references!
help!!!
etech0,

(1) Please see attached...

(2) "pass a variable to the clipboard in vba" - do you mean more than replacing 3.1415926 by a variable name?

Thanks,
Brian.
Avatar of etech0

ASKER

@redmondb: Huh?
as you may have noticed in my code, I have a variable called txt which stores the file name and location in the format I require.
I would like to "copy" the data in this variable to the clipboard, so that I can paste it in the location of my choice.
Oops.

(See 4th item).

 User generated image
Avatar of etech0

ASKER

I see, but I don't have that item in my list!
etech0,

Apologies, there's another DataObjects question open at the moment and I cross-posted.

The Forms reference is in the list, but the sequence in that dialogue can be peculiar.

Regards,
Brian.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of etech0

ASKER

Thanks all for your help!
"try clicking browse, navigate to c:\windows\system32 - you are looking for FM20.dll" did the trick!
Thanks, etech0. Good thinking regmigrant.