Hi,
I have the following code:
The issue is regarding initialFilename!
When the workbook is an template (that is, the filename does not contain any file format extension), this works great!
But if I have an xlsm-file (have saved the template), the initialFilename isn't inserted at all. I have tried the following code (just to see what value the code is returning):
and the value is the workbook's name including the file format extension (.xlsm).
What can I do the make the initialFilename to be the workbook name (without file format extension)?
I have the following code:
Code:
Dim fileSaveName As Variant
wbName = ActiveWorkbook.Name
fileSaveName = Application.GetSaveAsFilename(initialFilename:=wbName)
If VarType(fileSaveName) = vbBoolean Then Exit Sub
fileSaveName = Left(fileSaveName, Len(fileSaveName) - 1)
'Hvis Gemini Terreng & Entprenrenør
If Rows("63:63").Hidden = True Then
Dim varMyArray() As Variant 'Declares a dynamic array variable
Dim lngArrayCount As Long
Dim varMySheet As Variant
For Each varMySheet In Array("Rapport", "Rapport_Linjer", "Rapport_Punkt", "Rapport_Polygon", "Rapport_Tekst", "Rapport_Triangelnett")
If Len(Sheets(varMySheet).Range("A7")) > 0 Or varMySheet = "Rapport" Then
lngArrayCount = lngArrayCount + 1
ReDim Preserve varMyArray(1 To lngArrayCount) 'Append the record to the existing array
varMyArray(lngArrayCount) = varMySheet
End If
Next varMySheet
Sheets(varMyArray).Select
End If
' Save as PDF
Application.DisplayAlerts = True
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, fileName:=fileSaveName, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=True
The issue is regarding initialFilename!
When the workbook is an template (that is, the filename does not contain any file format extension), this works great!
But if I have an xlsm-file (have saved the template), the initialFilename isn't inserted at all. I have tried the following code (just to see what value the code is returning):
Code:
MsgBox (wbName)
What can I do the make the initialFilename to be the workbook name (without file format extension)?