I am wondering if there is a way to disable the "saveas" in excel from access with vba? I have the following code:
Private Sub cmdReport_Click()
Dim path As String
Dim XL As Object
Dim oBook As Excel.Workbook
Dim pic As Excel.Shape
Set XL = CreateObject("Excel.Application")
If IsNull(Me.RawReport) Or Me.RawReport = "" Then
MsgBox "There currently are no Raw Data Forms for this project", , "No File"
Else
path = HyperlinkPart(Me.RawReport, acAddress)
With XL.Application
.Visible = True
.AskToUpdateLinks = False
.Workbooks.Open path
.AskToUpdateLinks = True
XL.ActiveWorkbook.Worksheets("Ref").Unprotect
For Each pic In XL.ActiveWorkbook.Worksheets("Ref").Shapes
If pic.Name = Forms!Main!txtCurrentUser Then
pic.Copy
XL.Worksheets("TermsSig").Range("E12").Select
XL.Worksheets("TermsSig").Paste Destination:=XL.Worksheets("TermsSig").Range("E12")
With XL.Worksheets("TermsSig").Range("E12")
XL.Selection.ShapeRange.ScaleHeight 1.5020895209, _
msoFalse, msoScaleFromTopLeft
XL.Selection.ShapeRange.ScaleHeight 1.5020911212, _
msoFalse, msoScaleFromBottomRight
XL.Selection.ShapeRange.IncrementTop -20.5
XL.Selection.ShapeRange.IncrementLeft 7.75
End With
End If
Next pic
End With
End If
Set XL = Nothing
End Sub
I know that in excel, I can disable the "saveas" by using
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If SaveAsUI Then
MsgBox "Save As is disabled", vbInformation
Cancel = True
End If
End Sub
Which I have used in another excel file. But I can't use that now. The file I am opening from access is a workbook generated from an excel template, and I have yet to find a way on how to transfer this Workbook_BeforeSave sub from the template to the new workbook. Any suggestions on how to accomplish this? Thank you!
Private Sub cmdReport_Click()
Dim path As String
Dim XL As Object
Dim oBook As Excel.Workbook
Dim pic As Excel.Shape
Set XL = CreateObject("Excel.Application")
If IsNull(Me.RawReport) Or Me.RawReport = "" Then
MsgBox "There currently are no Raw Data Forms for this project", , "No File"
Else
path = HyperlinkPart(Me.RawReport, acAddress)
With XL.Application
.Visible = True
.AskToUpdateLinks = False
.Workbooks.Open path
.AskToUpdateLinks = True
XL.ActiveWorkbook.Worksheets("Ref").Unprotect
For Each pic In XL.ActiveWorkbook.Worksheets("Ref").Shapes
If pic.Name = Forms!Main!txtCurrentUser Then
pic.Copy
XL.Worksheets("TermsSig").Range("E12").Select
XL.Worksheets("TermsSig").Paste Destination:=XL.Worksheets("TermsSig").Range("E12")
With XL.Worksheets("TermsSig").Range("E12")
XL.Selection.ShapeRange.ScaleHeight 1.5020895209, _
msoFalse, msoScaleFromTopLeft
XL.Selection.ShapeRange.ScaleHeight 1.5020911212, _
msoFalse, msoScaleFromBottomRight
XL.Selection.ShapeRange.IncrementTop -20.5
XL.Selection.ShapeRange.IncrementLeft 7.75
End With
End If
Next pic
End With
End If
Set XL = Nothing
End Sub
I know that in excel, I can disable the "saveas" by using
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If SaveAsUI Then
MsgBox "Save As is disabled", vbInformation
Cancel = True
End If
End Sub
Which I have used in another excel file. But I can't use that now. The file I am opening from access is a workbook generated from an excel template, and I have yet to find a way on how to transfer this Workbook_BeforeSave sub from the template to the new workbook. Any suggestions on how to accomplish this? Thank you!