write file name into text file

yinkajewole

Active Member
Joined
Nov 23, 2018
Messages
281
how do i write the file name and path of my active workbook into a text file without putting it inside quotes i.e
c:\temp\col.xls
instead of
"c:\temp\col.xls"
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Hello yinkajewole,

Provided the active workbook has already been saved then you can use ThisWorkbook.FullName to return the path and name of the workbook.
 
Last edited:
Upvote 0
I used this Macro

Code:
Sub fullname()
MsgBox (ThisWorkbook.fullname)
End Sub

and it works for me.
 
Upvote 0
this is the macro I'm using

Code:
Sub fullname()Dim st As String
st = "C:\Users\USER\Desktop\History.txt"
Open st For Append As [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL] 
If ActiveWorkbook.Path = "" Then
Else
Write [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL] , (ThisWorkbook.fullname)
End If
Close [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL] 
End Sub
 
Upvote 0
how do i write the file name and path of my active workbook into a text file without putting it inside quotes i.e
this is the macro I'm using

Code:
Sub fullname()Dim st As String
st = "C:\Users\USER\Desktop\History.txt"
Open st For Append As [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1][URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL] [/URL] 
If ActiveWorkbook.Path = "" Then
Else
[B][COLOR="#FF0000"][SIZE=3]Write #1   [/SIZE][/COLOR][/B], (ThisWorkbook.fullname)
End If
Close [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1][URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL] [/URL] 
End Sub
Don't use Write #1 use Print #1 instead.
 
Last edited:
Upvote 0
Please, I would like to modify this code such that ThisWorkbook.fullname will remove any previous one and add the new one to the last line
Code:
Sub fullname()Dim st As Stringst = "C:\Users\USER\Desktop\History.txt"
Open st For Append As [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL]   
If ActiveWorkbook.Path = "" Then
Else
Print [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL] , [B]ThisWorkbook.fullname[/B]
End If
Close [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL]   
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top