×
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

Open PDF / save value to Clipboard

Open PDF / save value to Clipboard

Open PDF / save value to Clipboard

(OP)
Hi,

I have searched a lot for let my macro (swp in Solidworks) do two things:

1) opening a PDF in AcrobatReader after creating this PDF out of SW;
2) save a value to the windows clipboard

how can i do this?

regards, Peter

RE: Open PDF / save value to Clipboard

Not very pretty, and I don't know if it would be very reliable (or even work)... but once open maybe you could activate the PDF and do a SendKeys to accomplish Select All (either [Ctrl]+A or [Alt]+E+L), then Copy, you can then iterate thru the Clipboard Contents...maybe?

RE: Open PDF / save value to Clipboard

(OP)
I prefer to do it automaticly, out of my macro...

RE: Open PDF / save value to Clipboard

In Visual Basic:
"1) opening a PDF in AcrobatReader after creating this PDF out of SW;"
After saving the PDF you can use the API call ShellExecute

"2) save a value to the windows clipboard"
Clipboard.Clear
clipboard.settext "YourStringvalue"


Using ShellExecute
'Declare it
Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal _
    hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal _
    lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As _
    Long

'call it
ShellExecute Me.hwnd, "open", "yourpdffile.pdf", vbNullString, vbNullString, SW_SHOW

Francis
www.controldraw.co.uk
www.s88control.blogspot.com

RE: Open PDF / save value to Clipboard

Dim objData As New MSForms.DataObject
objData.SetText "Hello World!"
objData.PutInClipboard

objData.GetFromClipboard
Debug.Print objData.GetText
 

RE: Open PDF / save value to Clipboard

(OP)
Thanks for the support. The copy to clipboard statement is working, but after installing the 'Microsoft Forms 2.0 Object Library' This was missing in my VB references.

But how do i put the shell execute into my swp-macro? As a function, or in the Sub Main() ? And wich VB library does it need?

regards Peter

see also attached swp macro.

 

RE: Open PDF / save value to Clipboard

I found this method somewhere...

CODE

Option Explicit
 
Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal Hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
 
 
Sub Open_Pdf()
Dim PdfFile As String
Dim FDir As String
 
PdfFile = "ooslist.pdf" 'Pdf file name
FDir = "D:\HS" 'Directory where Pdf file exists
 
ShellExecute 0, "Open", PdfFile, "", FDir, 1
End Sub

 

RE: Open PDF / save value to Clipboard

(OP)
Thanks brengine! It works great!

regards Peter

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