|
|
 |
| 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.
|
 |

June 21st, 2007, 05:00 PM
|
|
Registered User
|
|
Join Date: Jun 2007
Location: , , USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

July 1st, 2007, 08:56 AM
|
|
Registered User
|
|
Join Date: Jul 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |