p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Visual Basic > VB 2005 > Visual Basic 2005 Basics
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 21st, 2007, 05:00 PM
Registered User
 
Join Date: Jun 2007
Location: , , USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Copy data to Excel

I need to be able to copy a text file to a specific sheet in an .xls file without Excel actually installed.

I have a VBSCRIPT that works perfectly if Excel is installed, but it does not work at all if Excel is not installed.

Here is the code:

Option Explicit

Dim objApp, objWbs, objWorkbook, objWorkbook2, objSheet, WshShell, objSheet2

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd.exe /C copy \\aragorn\Phx\Wksetup\Design\TESTING\750.WK1 \\aragorn\Phx\Wksetup\Design\TESTING\750.csv", 0, True

Set objApp = CreateObject("Excel.Application")
Set objWbs = objApp.WorkBooks
objApp.Visible = False
Set objWorkbook = objWbs.Open("\\aragorn\Phx\Wksetup\Design\TESTING\ 750.wk1")
Set objWorkbook2 = objWbs.Open("\\aragorn\Phx\Wksetup\Design\TESTING\ PhxAmpBlkswk1stocsvs.xls")
Set objSheet = objWorkbook2.Sheets("750_wk1")
Set objSheet2 = objWorkbook2.Sheets("750 sort")

objWorkbook.Sheets(1).UsedRange.Copy objSheet.Range("A1")
objSheet2.PrintOut
objWorkbook2.Save

objWorkbook.Close False
objWbs.Close
objApp.Quit

Set objSheet = Nothing
Set objWorkbook = Nothing
Set objWbs = Nothing
Set objApp = Nothing

Sincerely,

George Jackson

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old July 1st, 2007, 08:56 AM
Registered User
 
Join Date: Jul 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If you havn't figured out the solutions yet.
Import Office COM's
import these
1) Microsoft.Office.Interop.Excel.dll
2) Microsoft.Vbe.Interop.dll
3) Microsoft.Vbe.Interop.Forms.dll
4) office.dll

and your code will work fine even without Office Installed.
you can download the Office 2003 Primary Interop Assemblies from
Microsoft Corp. Its a 5 MB Package that contains office assemblies which can be used to create applications that interact with Office
tools & Apps.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
XMLSpy: copy data from excel, paste in XMLSpy 2004 xmler XML 1 November 26th, 2008 03:33 AM
Copy data from Excel to open HTML form Bartje Excel VBA 1 September 29th, 2006 05:02 AM
Copy data from webpage to excel using vba kg8299 Excel VBA 0 April 5th, 2006 04:51 AM
Copy Excel file to database kiwibey ASP Forms 3 December 14th, 2004 05:30 AM
Copy Data from Access.mdb into an Excel Spreadshee KennethMungwira ADO.NET 2 January 23rd, 2004 10:46 AM



All times are GMT -4. The time now is 11:01 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc