×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Copy string value to windows clipboard from API

Copy string value to windows clipboard from API

Copy string value to windows clipboard from API

(OP)
Is there a way to copy a string's value within a macro (value entered into an INPUTBOX) to windows clipboard?  I'm using SolidWorks 2005 currently.  The EditCopy function appears to be what I'm supposed to use, but my API help file is very unclear on how to use it, and I can't get it to work.

Matt
CAD Engineer/ECN Analyst
Silicon Valley, CA
http://sw.fcsuper.com/index.php

RE: Copy string value to windows clipboard from API

You would need to use the clipboard functions that are part of either Office or standard VBA, I forget which.  

RE: Copy string value to windows clipboard from API

(OP)
Ok, thank you.  I can use that, but I still gotta ask: no way to do it directly from a module with an InputBox include of having to use a userform?

Matt
CAD Engineer/ECN Analyst
Silicon Valley, CA
http://sw.fcsuper.com/index.php

RE: Copy string value to windows clipboard from API

fcsuper,

A suggestion: I would take out all the references to SolidWorks in the References dialog.  I no longer have SolidWorks 2005 installed on my computer.  The macro would not run until I unchecked Solidworks Utilities 2005 Type Library.  This will allow the macro to run with any version of SolidWorks without the user having to figure out or complain to you why the macro will not run.

SA

RE: Copy string value to windows clipboard from API

Sure.  Just remove the UserForm entirely and change your code to:

CODE

Dim I As Integer
Dim J As Integer
Dim dataStr As String
Dim buildStr As String
Dim tempStr As String
Dim Done As Boolean

''''''''''''''''''
Dim myData As New MSForms.DataObject  'This line was moved from the UserForm code
''''''''''''''''''


Sub main()

    buildStr = ""
    
    dataStr = "Use ALT + Keypad for special characters.  Examples:" + Chr(13)
        dataStr = dataStr + "171 = " + Chr(189) + "      172 = " + Chr(188) + _
        "      241 = " + Chr(177) + Chr(13)
        dataStr = dataStr + "250 = " + Chr(183) + "      253 = " + Chr(178) + _
                      "      248 = " + Chr(186) + Chr(13) + Chr(13)
        dataStr = dataStr + "Choose OK to copy to clipboard." + Chr(13)
    
        
    tempStr = buildStr
    buildStr = InputBox(dataStr, "Editor Special Characters", tempStr)
        
        If buildStr <> "" Then
''''''''''''''''''''''''
             myData.SetText buildStr    'Remove the UserForm reference
             myData.PutInClipboard        'from these two lines
''''''''''''''''''''''''
        End If
    
End Sub

You do still have to include the Microsoft Forms reference, but you don't have to have an actual form in the macro.

RE: Copy string value to windows clipboard from API

(OP)
Thanks guys.  

Apparently I've been sold on a fantasy that SolidWorks is supposed to know when to use current libraries instead of past versions.  I'm going to go through all of my macros to see where this might bring up an issue.  Anyways, new update:

http://sw.fcsuper.com/index.php?name=UpDownload&req=viewdownloaddetails&amp;lid=32

BTW, I'm still working on building my site up, I want to create a site that would've been helpful to me when I first started out making macros and customizing SolidWorks.  Comments are welcome, and I will appreciate any public domain or freeware submissions or website links I might be missing (feel free to register on the site).

Matt
CAD Engineer/ECN Analyst
Silicon Valley, CA
http://sw.fcsuper.com/index.php

RE: Copy string value to windows clipboard from API

(OP)
Actually, what is the deal with those libraries?  Some are essential.  Some SolidWorks installations seem to know to use the current version of them, and others do not.  I was told before by my VAR that any macro should be useable on any higher version of SolidWorks where libraries are concerned.  
Has anyone else run into issues with libraries?

Matt
CAD Engineer/ECN Analyst
Silicon Valley, CA
http://sw.fcsuper.com/index.php

RE: Copy string value to windows clipboard from API

handleman.

What is the exact name of the MS Forms library?

SA

RE: Copy string value to windows clipboard from API

Do you mean the filename of the DLL? It's FM20.dll, most likely located in C:\WINDOWS\system32.  In the References dialog it shows up as "Microsoft Forms 2.0 Object Library".

RE: Copy string value to windows clipboard from API

handleman,

Thanks, that DLL was not in my references dialog.

SA

RE: Copy string value to windows clipboard from API

fcsuper,

Here is another option.  Try this macro:

http://www.mooload.com/new/file.php?file=files/301106/1164851566/Clipboard2.swp

It is based on code written by Bob Bedell that I found at :http://p2p.wrox.com/topic.asp?TOPIC_ID=15747

My first post with handleman's enhancement is much cleaner in my opinion but, if someone else was like me and did not have the FM20.dll loaded, this will eliminate you having to post solutions to possible problems with the macro not running.

SA

RE: Copy string value to windows clipboard from API

(OP)
SolidAir,

Your clipboard2 is a macro by its own right.  Thank you.

Matt

Matt
CAD Engineer/ECN Analyst
Silicon Valley, CA
http://sw.fcsuper.com/index.php

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources