ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ThisWorkbook.Path (https://www.excelbanter.com/excel-programming/290821-thisworkbook-path.html)

Birdy

ThisWorkbook.Path
 
I have the following problem.

I want to save the active workbook and make an empty backup in the same
directory.
Code works nice, but only once.
Next execute of code the default dir of windows is used and creates a
problem.

Sub opslaan_evenement()
'
' save_event Macro
' write empty backup as "AWR leeg" in same dir
'

naam2 = Cells(1, 1)
naam3 = ThisWorkbook.Path
naam4 = naam3 + "\" + naam2

Application.DisplayAlerts = False
ActiveWorkbook.SaveAs (naam4)
Sheets(1).Select
Range("C7:F357").Select
Selection.ClearContents
ActiveWorkbook.SaveAs ("AWR leeg")
Application.DisplayAlerts = True
'
End Sub


Mayby someone can help me !



mudraker[_148_]

ThisWorkbook.Path
 
With your code

ActiveWorkbook.SaveAs ("AWR leeg")

you need to supply a path as well or change to that directory befor
saving

eg

ActiveWorkbook.SaveAs (thisworkbook.path & "\AWR leeg"

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 10:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com