Could you explain a bit more about the process. What applications is running and from where is the macro thought to be executed? What should happen in the excel file?
Thanks a lot Daniel for your fast answer.
The proccess is as follows:
- The user introduce the name of the Solidworks file (SLDPRT, SLDASM, SLDDRW) on an input field (textbox) in an Access form.
- The form has an activex control (edrawings API) to show on the screen the selected file.
- Then there is a command button that is press by the user, and i link the button to VBA code.
- That VBA code is where i want to do a "SAVE AS", so what i need is to save the active file as a .JPG file
- The user will use that JPG file to put some notes and to do little changes.
I have to say that the user don´t have Solidworks on his system, but just Edrawings
I hope this help you to understand what i want, if not please don´t hesitate to ask me.
Thank you very much.
Sounds like you have things going.
You could try the IEModelViewControl::Save Method.
Thanks for your help Daniel.
I am sorry but a have that found before. The problem is that it is programmed in Visual Basic (VB) and what i need is Visual Basic for Aplications (VBA), so i can not use that code with MS Access.
The eDrawing API is use able in vba as well. You have to add it as refenced library in the vba editor for the macro you are creating.
Have a look at Tools -> References in the vba editor in MS Access. There should be a eDrawing reference to select there.
Thanks again Daniel.
That is my problem, i found some references to do it, but i don´t understand the syntax of them, this is because i am new on VBA.
Here is my code:
Option Compare Database
'To do the SAVE AS, when the user press a command button this part of the program runs
Private Sub PrintB_Click()
Dim file As String
file = "C:\asc\planosorig\" & Refer & ".SLDPRT"
Me.DWGImage.OpenDoc file, False, False, False, ""
file = "C:\asc\test.jpg"
EModelViewApp.SaveActiveDocumentAs (file) - THIS INSTRUCTION IS THE ONE FAILING, IT MUST BE SOMETHING STUPID, BUT I CAN´T SOLVE IT
'View the Solidwors file of the selected part number, done in an Edrwawings ActiveX of the Form
Private Sub Refer_AfterUpdate()
coutst = "C:\asc\planosorig\" & Refer & ".SLDPRT"
DWGImage.Visible = True
DWGImage.OpenDoc coutst, 0, 0, 0, ""
Not sure if you solved it or not... but I do not regongnize the methods your are using for the DWGImage object. They are not found in the API where I look for the eDrawings 2014 API.
But it was quite straight forward since it is a inserted object. I tested this out in Excel 2013, should be similar in MS Access as well.
Inserted the eDrawings Active X by the Developer tab in Excel, click Insert, then More controls. Scroll down to eDrawings.
Add the object to the size you want...
Then I added two buttons... made this macro as below.
Cell B1 = C:\part1.sldprt
Cell B2 = C:\test1.jpg
Sheet1.EModelViewControl1.OpenDoc Sheet1.Cells(1, 2), False, False, True, ""
Sheet1.EModelViewControl1.Save Sheet1.Cells(2, 2), False, "" 'Save to the file as stated in cell B2
I attached the excel file as well. The excel example was done with eDrawing 2014 x64.
EDIT 2014-12-04: Updated example so the open Solidworks document can be changed.
Book1.xlsm 20.2 KB
¡You are the master!
Thanks a lot, it was so hard for me and you did it in the most simple way.