Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old September 12th, 2003, 03:50 AM
Eagle Eye Eagle Eye is offline
A disaster looking to happen
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Berkshire, UK
Posts: 6 Eagle Eye User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 50 sec
Reputation Power: 0
Saving embedded image to disc

I am using VBA (Excel) to automate a process.

In Excel in have the following code:

ActiveSheet.OLEObjects.Add(Filename="C:\sample.mid", link = false, DisplayAsIncon = false).select

This works as expected.

However what I need to be able to do is, using a seperate VBscript, save this file to disc.

It's probably very obvious but I can't see how to do it. Can somebody tell me how ? (and can I use the same technique for jpg files?)

Thank you

Last edited by Eagle Eye : September 12th, 2003 at 03:57 AM.

Reply With Quote
  #2  
Old September 16th, 2003, 12:34 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via MSN to cleverpig
You would try export method or saveas method.
http://www.4guysfromrolla.com/webtech/022801-1.shtml

Private Sub createPage()
'Declarations
Dim ExcelAp As New Excel.Application()
Dim ExcelWb As Excel.Workbook
Dim ExcelWs As Excel.Worksheet
ExcelAp.Application.SheetsInNewWorkbook = 1
ExcelWb = ExcelAp.Workbooks.Add
ExcelWs = ExcelWb.ActiveSheet

'Show the created excel worksheet
ExcelWs.Application.Visible = True

'Add data to the sheet
ExcelWs.Name = "Report"
ExcelWs.Cells(1, 1).Value = "Machine Number" 'In cell A1 the text 'Test1' will be placed.
ExcelWs.Cells(1, 2).Value = "Client"
ExcelWs.Cells(1, 3).Value = "City"
ExcelWs.Cells(1, 4).Value = "State"
ExcelWs.Cells(1, 5).Value = "Contact"
ExcelWs.Cells(1, 6).Value = "Contact#"
ExcelWs.Cells(1, 7).Value = "Contact Email"
ExcelWs.Cells(1, 8).Value = "Citrix Y/N"
ExcelWs.Cells(1, 9).Value = "Comments/Updated Info"

' Save the sheet to C:\Test.xls directory.
ExcelWs.SaveAs("Test.xls")

'Close Workbooks
ExcelWb.Close()
ExcelAp.Quit()

'Close all objects
ExcelWs = Nothing
ExcelWb = Nothing
ExcelAp = Nothing

End Sub

Reply With Quote
  #3  
Old September 16th, 2003, 02:33 AM
Eagle Eye Eagle Eye is offline
A disaster looking to happen
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Berkshire, UK
Posts: 6 Eagle Eye User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 50 sec
Reputation Power: 0
Thanks for that but I obviously didn't make myself clear.

What I actually what to be able to do is to save the embedded object to a file not the whole spresadsheet.

Reply With Quote
  #4  
Old September 23rd, 2003, 12:40 AM
egger egger is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Montreal,Canada
Posts: 17 egger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I am trying to do a similar thing -

I have taken over a site design project for a customer using ASP and MS-SQL..

They would like an inventory page based on a huge excel file. To start with, they gave me a small one with 200 rows, but they have a bigger 2000 row sheet. Column 1 is a description, column 2 is a unique product id, and column 3 is some sort of copy and pasted image of the product, and I need to display these on the page.

I guess I want to somehow export all the images in the 3rd column into individual jpg files, and name them according to the id. For instance, the image that is sitting in the third column of productid 1234 would be saved as 1234.jpg - then I could export the sheet as a CSV and make a simple database query to display the description, id, and image.

I have no idea how to go about exporting these images from Excel in any convenient fashion, and name them according to another column in the row. Any ideas?

Reply With Quote
  #5  
Old September 23rd, 2003, 11:47 AM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,687 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 4 Weeks 1 Day 16 h 39 m 15 sec
Reputation Power: 688
VB has a SavePicture statement that will extract a graphic to a file, but I don't know if it's in Excel VBA or not.

Reply With Quote
  #6  
Old September 23rd, 2003, 01:44 PM
egger egger is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Montreal,Canada
Posts: 17 egger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks, Doug -

SavePicture _does_ seem ideal, but it is not in the Methods section of the MSDN MS Excel VB Reference. Nonetheless, I tried it with the first picture by executing this statement:

--->
Set myDocument = Worksheets(1)
SavePicture myDocument.Shapes(1), "C:/test.bmp"
<---

...as a macro. the error I got was:

--->
Run-time error 13
Type mismatch.
<---

This seems to suggest that the method is available, but I am passing the wrong thing to it (Shape). Since the method documentation is not where I would think it is in MSDN, I still think this might be worth pursuing, if I only knew what to pass it.

Am I flogging a dead horse trying to get this to work with Excel VB, or am I just passing a wrong argument type?

Reply With Quote
  #7  
Old September 23rd, 2003, 03:12 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,687 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 4 Weeks 1 Day 16 h 39 m 15 sec
Reputation Power: 688
If the savepicture method is not documented in the Excel VBA documentation I wouldn't try to use it in my code. And I don't see anything about this statement in Excel 2000 VB reference. I searched the Excel online help for savepicture and nothing showed up.

Reply With Quote
  #8  
Old September 23rd, 2003, 03:25 PM
egger egger is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Montreal,Canada
Posts: 17 egger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks Doug. I guess I was hoping for a miracle. I am using Excel 2002, and came to the same conclusion.

To cut my losses, I will just go forward doing each one manually. If anyone has a good idea, I'd love to hear it before the 2000 some-odd row spreadsheet comes my way!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Saving embedded image to disc


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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 On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway