hexagon logo

PC-Dmis to Excel, through PC-Dmis Script

I know there is currently a VB project that runs in Excel during execution that will pull information into the workbook during execution. I decided to venture out and try some of my own approaches with a combination of data I found online here and there.

What I have is a script that can be executed in program, without too much setup and hassle, that will export data into an excel workbook like a print command would. I feel this script offers a little more versatility.

I will not claim ownership of this program. I just tweaked it to fit my needs. So far I have it running, and it works quite well.

I will answer what questions I can, but for the most part I wanted to post it to have as a reference.

It's a long program........
Parents
  • Drop-In Script part1

    Sub Main 
    'pcdlrn declarations And Open ppg
    Dim App As Object
    Set App = CreateObject("PCDLRN.Application")
    Dim Part As Object
    Set Part = App.ActivePartProgram
    Dim Ew As Object
    Set Ew = Part.EditWindow
    Dim Cmds As Object
    Set Cmds = Part.Commands
    Dim Cmd As Object
    Dim DCmd As Object
    Dim DcmdID As Object
    Dim ObjFso
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    'Excel Declarations
    Dim xlApp As Object
    Set xlApp = CreateObject("Excel.Application")
    Dim xlWorkbooks As Object
    Set xlWorkbooks = xlapp.Workbooks
    Dim xlWorkbook As Object
    Dim xlSheet As Object
    Dim fncSheet As Object
    Dim count As Integer
    Dim xlWorksheets As String 
    Dim xlWorksheet As String 
    Dim DimID As String 
    Dim ReportDim As String
    Dim CheckDim As String 
    Dim FilePath, SheetPath As String
    'Check To see If results file exists
    myTitle$ = "User Input"
    Prompt$ = "Please Input Directory for blank Excel Document, or Reference Document.  Including file name."
    Default$ = "C:\"
    FilePath = InputBox$(Prompt$, myTitle$, Default$)
    myTitle$ = "User Input"
    Prompt$ = "Please Input Sheet Name for Data Population"
    Default$ = "Sheet1"
    SheetPath = InputBox$(Prompt$, myTitle$, Default$)
    ResFileExists = FilePath & ".xlsx"
    Dim TempFilename,TempSheetName
    TempSheetName = SheetPath
    If objFSO.FileExists(ResFileExists) = False Then
        'If the file did Not exist, Then use a default file location stored As a precaution
        TempFilename = "X:\00 Sub Folders\13 Engineering\09 Inspection\02 CMM Programs & Documentation\" & "Prog Template.xlsx"
       [COLOR=#FF0000][B] '^^ You need to adjust this line to fit your needs.  This is a security line to always point to a guaranteed excel document for use. _
        'Ex.  "C:\Test.xlsx"[/B][/COLOR]
    Else
        TempFilename = ResFileExists
    End If
    On Error GoTo ErrorCheck
    
    
Reply
  • Drop-In Script part1

    Sub Main 
    'pcdlrn declarations And Open ppg
    Dim App As Object
    Set App = CreateObject("PCDLRN.Application")
    Dim Part As Object
    Set Part = App.ActivePartProgram
    Dim Ew As Object
    Set Ew = Part.EditWindow
    Dim Cmds As Object
    Set Cmds = Part.Commands
    Dim Cmd As Object
    Dim DCmd As Object
    Dim DcmdID As Object
    Dim ObjFso
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    'Excel Declarations
    Dim xlApp As Object
    Set xlApp = CreateObject("Excel.Application")
    Dim xlWorkbooks As Object
    Set xlWorkbooks = xlapp.Workbooks
    Dim xlWorkbook As Object
    Dim xlSheet As Object
    Dim fncSheet As Object
    Dim count As Integer
    Dim xlWorksheets As String 
    Dim xlWorksheet As String 
    Dim DimID As String 
    Dim ReportDim As String
    Dim CheckDim As String 
    Dim FilePath, SheetPath As String
    'Check To see If results file exists
    myTitle$ = "User Input"
    Prompt$ = "Please Input Directory for blank Excel Document, or Reference Document.  Including file name."
    Default$ = "C:\"
    FilePath = InputBox$(Prompt$, myTitle$, Default$)
    myTitle$ = "User Input"
    Prompt$ = "Please Input Sheet Name for Data Population"
    Default$ = "Sheet1"
    SheetPath = InputBox$(Prompt$, myTitle$, Default$)
    ResFileExists = FilePath & ".xlsx"
    Dim TempFilename,TempSheetName
    TempSheetName = SheetPath
    If objFSO.FileExists(ResFileExists) = False Then
        'If the file did Not exist, Then use a default file location stored As a precaution
        TempFilename = "X:\00 Sub Folders\13 Engineering\09 Inspection\02 CMM Programs & Documentation\" & "Prog Template.xlsx"
       [COLOR=#FF0000][B] '^^ You need to adjust this line to fit your needs.  This is a security line to always point to a guaranteed excel document for use. _
        'Ex.  "C:\Test.xlsx"[/B][/COLOR]
    Else
        TempFilename = ResFileExists
    End If
    On Error GoTo ErrorCheck
    
    
Children
No Data