R
rockhammer
I have a macro in sourceFile which opens a destFile to copy data from
sourceFile into destFile and then tries to save the destFile. My destFile in
this case is one which has a modify password set and also has the open
read-only recommended option set.
What I am experiencing is that even though I enter the password when the
prompt comes up when the destFile is opened and I click "ok" instead of "read
only", the destFile is still opened as read-only.
My question is: Is there a way to modify my code such that the destFile will
NOT be opened read only when the proper password is entered when prompted?
Excerpts of my code below - it all works except that destFile is always
opened read only no matter what and therefore the line that saves the
destFile gives an error.
Thanks a lot.
' this is the file open sub
Sub threed_file_open()
fileOpened = False
Application.DisplayAlerts = False
Application.ScreenUpdating = False
If Not fileSelected Then
MsgBox "No 3D template file selected yet!"
Exit Sub
End If
sourceFile = ActiveWorkbook.Name
Workbooks.Open Filename:=sourceFileName, Notify:=False
fileOpened = True
destFile = ActiveWorkbook.Name
Windows(sourceFile).Activate
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
' this is the code which does the copying & saving
Windows(sourceFile).Activate
topbot.Activate ' this is the tab in sourceFile I want to copy from
Range(topbotExport1stCell, topbotExportLastCell).Select
Selection.Copy
Windows(destFile).Activate
Worksheets(topbotImportTab).Activate
topbotImportCell.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
ActiveWorkbook.Save
MsgBox "Changes to " & destFile & " saved."
sourceFile into destFile and then tries to save the destFile. My destFile in
this case is one which has a modify password set and also has the open
read-only recommended option set.
What I am experiencing is that even though I enter the password when the
prompt comes up when the destFile is opened and I click "ok" instead of "read
only", the destFile is still opened as read-only.
My question is: Is there a way to modify my code such that the destFile will
NOT be opened read only when the proper password is entered when prompted?
Excerpts of my code below - it all works except that destFile is always
opened read only no matter what and therefore the line that saves the
destFile gives an error.
Thanks a lot.
' this is the file open sub
Sub threed_file_open()
fileOpened = False
Application.DisplayAlerts = False
Application.ScreenUpdating = False
If Not fileSelected Then
MsgBox "No 3D template file selected yet!"
Exit Sub
End If
sourceFile = ActiveWorkbook.Name
Workbooks.Open Filename:=sourceFileName, Notify:=False
fileOpened = True
destFile = ActiveWorkbook.Name
Windows(sourceFile).Activate
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
' this is the code which does the copying & saving
Windows(sourceFile).Activate
topbot.Activate ' this is the tab in sourceFile I want to copy from
Range(topbotExport1stCell, topbotExportLastCell).Select
Selection.Copy
Windows(destFile).Activate
Worksheets(topbotImportTab).Activate
topbotImportCell.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
ActiveWorkbook.Save
MsgBox "Changes to " & destFile & " saved."