Shades047
05-27-2017, 01:52 PM
Hello,
I am trying to set the default Save As name for an Excel workbook that was created through LabVIEW. The LabVIEW program opens a new Excel workbook from a template, populates it with data, and does some analysis. When doing the same thing in Word, this was the macro that could make that work:
Sub ChangeProps()
'change properties
If Documents.Count > 0 Then
Set dlgProp = Dialogs(wdDialogFileSummaryInfo)
' Establish title, subject, author, and keywords values
dlgProp.Title = MakeADocTitle(LVTitle)
dlgProp.Subject = LVSubject
dlgProp.Author = LVAuthor
dlgProp.Comments = LVComments
' Set the values
dlgProp.Execute
' Show the dialog for testing purposes
'dlgProp.Show
End If
End Sub
Function MakeADocTitle(ByVal strTitle As String) As String
arrSplit = Split(strTitle, " ")
MakeADocTitle = arrSplit(0)
For I = 1 To UBound(arrSplit)
MakeADocTitle = MakeADocTitle & Chr(95) & arrSplit(I)
Next I
MakeADocTitle = MakeADocTitle
End Function
Because for some reason just setting the "Title" property in a Word document does not set the default SaveAs name. This is also true of Excel, but I couldn't adapt that macro to work in Excel. The reason why I want to do this is because this is being used by the guys out in the machine shop, and we want to save the Excel files as "serial number.xls", like "SN55698755.xls". Because they will be doing this over and over and the serial numbers are all a bit samey, I want the computer to fill in the title for them so that they don't have to worry about making a mistake.
Is there a similar macro that does the same job in Excel? I am sorry if this is a super basic question. I tried Googling this about a dozen different ways, but they all seem to involve opening a dialog box, which doesn't work from LabVIEW (maybe doesn't work from 3rd party programs at all?). Even just telling me the right word to search for would be a big help.
I am trying to set the default Save As name for an Excel workbook that was created through LabVIEW. The LabVIEW program opens a new Excel workbook from a template, populates it with data, and does some analysis. When doing the same thing in Word, this was the macro that could make that work:
Sub ChangeProps()
'change properties
If Documents.Count > 0 Then
Set dlgProp = Dialogs(wdDialogFileSummaryInfo)
' Establish title, subject, author, and keywords values
dlgProp.Title = MakeADocTitle(LVTitle)
dlgProp.Subject = LVSubject
dlgProp.Author = LVAuthor
dlgProp.Comments = LVComments
' Set the values
dlgProp.Execute
' Show the dialog for testing purposes
'dlgProp.Show
End If
End Sub
Function MakeADocTitle(ByVal strTitle As String) As String
arrSplit = Split(strTitle, " ")
MakeADocTitle = arrSplit(0)
For I = 1 To UBound(arrSplit)
MakeADocTitle = MakeADocTitle & Chr(95) & arrSplit(I)
Next I
MakeADocTitle = MakeADocTitle
End Function
Because for some reason just setting the "Title" property in a Word document does not set the default SaveAs name. This is also true of Excel, but I couldn't adapt that macro to work in Excel. The reason why I want to do this is because this is being used by the guys out in the machine shop, and we want to save the Excel files as "serial number.xls", like "SN55698755.xls". Because they will be doing this over and over and the serial numbers are all a bit samey, I want the computer to fill in the title for them so that they don't have to worry about making a mistake.
Is there a similar macro that does the same job in Excel? I am sorry if this is a super basic question. I tried Googling this about a dozen different ways, but they all seem to involve opening a dialog box, which doesn't work from LabVIEW (maybe doesn't work from 3rd party programs at all?). Even just telling me the right word to search for would be a big help.