Consulting

Page 2 of 2 FirstFirst 1 2
Results 21 to 31 of 31

Thread: Engineering Work Project

  1. #21
    VBAX Regular
    Joined
    Dec 2012
    Posts
    19
    Location
    Ok, I will attach the documents I am working. First Attachment is the AutoCAD drawing that I will be trying to insert all the tables from the excel doc into. Second is the actual excel document that I am currently trying to have my Code as for a tool number and insert it into the "UserInput Box". I will also attach my current code. This only error it is having right now is with the line that is suppose to input the inputbox's toolnumber into excel.

    ok...how do I attach an excel doc and a autocad drawing?

  2. #22
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    When you go to post a comment select go advanced then at the top of the form there is a paper clip select that and it will take you to an area that lets you upload the files. It will not let you upload a drawing so rename it to a .txt extension and i can deal with it from there.

  3. #23

  4. #24
    VBAX Regular
    Joined
    Dec 2012
    Posts
    19
    Location
    Alright, here is a zip file of both documents Bbl2000x Model (1).zip

    and her is my current code.

    Option Explicit
    Function InputToolNum()
    Dim UserInput As String
    UserInput = InputBox("Please Input Tool Number.")

    End Function

    Sub Main()
    'Open the excel spreadsheet
    Dim ExcelApp As Excel.Application
    OpenTemplateDrawing
    Set ExcelApp = GetExcel
    OpenWorkBook ExcelApp, "G:\Quattro Pro\EXEL\270XXL.xls"

    'Inputs Tool Number into Excel'
    Dim UserInput As String
    Dim ThisWorkBook As Object
    ThisWorkBook.Cells(5, 4).Value = UserInput

    End Sub
    Sub OpenTemplateDrawing()
    'Open the AutoCAD Drawing Template
    Application.Documents.Open ("J:\Bbl2000x")

    End Sub

    Function GetExcel() As Excel.Application
    Set GetExcel = CreateObject("Excel.Application")
    If GetExcel Is Nothing Then
    MsgBox "Excel doesn't like us!" '<- means excel didn't open
    End If
    GetExcel.Visible = True

    End Function
    Sub OpenWorkBook(Xl As Excel.Application, WB As String) '<-have the full path with the name of the workbook
    Xl.Workbooks.Open WB

    End Sub

  5. #25
    VBAX Regular
    Joined
    Dec 2012
    Posts
    19
    Location
    Nevermind, I got that cell insertion part to work. Now to display the tables in the drawing!

  6. #26
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    Evan here is a acad project file. it will load the drawing and the spread sheet. then it will read the spreadsheet for the tools numbers and the user will have the opportunity to select the tool they desire to draw. I would have started drawing but I don't know what fields to pick up and what to do then.
    Attached Files Attached Files

  7. #27
    VBAX Regular
    Joined
    Dec 2012
    Posts
    19
    Location
    Quote Originally Posted by Tommy
    Evan here is a acad project file. it will load the drawing and the spread sheet. then it will read the spreadsheet for the tools numbers and the user will have the opportunity to select the tool they desire to draw. I would have started drawing but I don't know what fields to pick up and what to do then.
    I would like it to read and insert Cell(C30:C69) and Cell(F30:F69). Also, did you do this in AutoCAD 2011 because I am having a hard time opening it on AutoCAD 2013.

  8. #28
    VBAX Regular
    Joined
    Dec 2012
    Posts
    19
    Location
    Ok, so i was able to get it open. But I am not quite sure how to run it exactly

  9. #29
    VBAX Regular
    Joined
    Dec 2012
    Posts
    19
    Location
    Actually, I have a more important question for anyone who can answer. I know I can select certain cells in excel and copy them and then paste them into my AutoCAD drawing. But I would like to know how to do that with code in autocad?

  10. #30
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    There is no advantage to do that. All you are doing is embedding the spreadsheet into the acad drawing. It is called OLE linking and embedding. I would help more but I have a job to finish detailing.

  11. #31
    VBAX Regular
    Joined
    Dec 2012
    Posts
    19
    Location
    Quote Originally Posted by Tommy
    There is no advantage to do that. All you are doing is embedding the spreadsheet into the acad drawing. It is called OLE linking and embedding. I would help more but I have a job to finish detailing.
    Ok, I will look into the OLE linking and embedding. Thanks for all your help Tommy, I would not have gotten anywhere without your advice.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •