Solved

Excel VBA (Copy / Paste To Another Application)

Posted on 2010-08-15
12
482 Views
Last Modified: 2012-08-13
I have copied a range of durations, start dates and finish dates from excel to the office clipborad in excel vba.

I have then used a hyperlink function to jump into an MS project file.

    Range("C26:E80").Select
    Selection.Copy
    Range("B91").Select
    Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True

How can i past the contents of the office clipboard into my project file.

Your support will be greatly appreciated.
0
Comment
Question by:SweetingA
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
  • 2
  • +1
12 Comments
 
LVL 17

Accepted Solution

by:
wobbled earned 500 total points
ID: 33443978
The only way I think you can do this is to create an instance of MS Project within the Excel VBA.

You would set it as something like:  

Dim objProj as Object
Set objProj  = CreateObject("Project.Application")
With o
'do your automation stuff here
'guessing something like o.tasks.paste.......etc
End With
'Close the object

not sure what the correct syntax is for opening project so just guessed the Project.Application bit
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 33444081
Try this routine instead

Sub copytomsp()
Set msp = GetObject(, "MSProject.Application")
    Range("C26:E80").Select
    Selection.Copy
    msp.EditPaste
End Sub
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 33444087
Sorry, wobbled. Did not see your post. The page was opened for a long time without refresh

Saqib
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Expert Comment

by:wobbled
ID: 33444125
not a problem Saqib - I do that all the time :)
0
 

Author Comment

by:SweetingA
ID: 33447705
I will accpet the solution, it works fine thanks

Just one more question first - is it possible to specify where the data will be pasted like in excel (i.e. cell range)




0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 33447836
Yes it is. But I do not know how. I might be able to find ways but not such that I can define it here. I suggest that you make trials with the macro recorder in MSProject. That is where I got the code from.

Saqib
0
 

Author Comment

by:SweetingA
ID: 33448636
ok, good idea
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 33448738
Hello there. Are you sure you accepted the appropriate solution. I think I provided you with a working solution whereas the accepted solution was merely a guideline. Did you use my solution to achieve what you wanted or the first one?
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 33495686
The accepted solution should be


ssaqibh #33444081
0
 
LVL 5

Expert Comment

by:Netminder
ID: 33528383
coolleomod,

See http://www.experts-exchange.com/Q_26426940.html

I disagree. Wobbled posted the solution first (which ssaqibh acknowledges). There is EVERY reason to think the follow-up was intended for Wobbled, and ssaqibh responded -- but that doesn't mean that the Asker's selection should be overturned.

Netminder
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 33528891
Ok I give up. But I still maintain that "works fine" referred to my solution.

Thanks for taking the time.

Saqib
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question