Code:
Public Sub WriteFile()
Dim intUnit As Integer
Dim rngRow As Range
Dim rngCell As Range
Dim strText As String
' Prompt user to select a file
With Application.FileDialog(msoFileDialogOpen)
.InitialFileName = ThisWorkbook.Path & Application.PathSeparator & "*.txt"
.Title = "Please Select a Text File"
.AllowMultiSelect = False
.Show
If .SelectedItems.Count = 0 Then Exit Sub ' User clicked cancel
strText = .SelectedItems(1)
End With
intUnit = FreeFile
Open strText For Output As intUnit
With Worksheets("Export").UsedRange
For Each rngRow In .Rows
strText = ""
For Each rngCell In rngRow.Cells
If Len(rngCell.Value) = 0 Then Exit For
strText = strText & "" & rngCell.Value
Next
Print #intUnit, (strText)
Next
End With
Close intUnit
End Sub
Hi Alphafrog
how can i amend this code for a powerpoint file?
thisworkbook.path wont work with powerpoint
With Application.FileDialog(msoFileDialogOpen)
.InitialFileName = ThisWorkbook.Path & Application.PathSeparator & "*.txt"
.Title = "Please Select a Text File"
.AllowMultiSelect = False
.Show
If .SelectedItems.Count = 0 Then Exit Sub ' User clicked cancel
strText = .SelectedItems(1)
End With
say i selected a powerpoint presentation, how can i amend accordingly?
I dont want to use thisworkbook .path
i want to have the path and file selected
in the variable
so say i selected a powerpoint slide from a specific folder
i want the variable to give me the full path and filename selected
Public Sub WriteFile()
Dim intUnit As Integer
Dim rngRow As Range
Dim rngCell As Range
Dim strText As String
' Prompt user to select a file
With Application.FileDialog(msoFileDialogOpen)
.InitialFileName = ThisWorkbook.Path & Application.PathSeparator & "*.txt"
.Title = "Please Select a Text File"
.AllowMultiSelect = False
.Show
If .SelectedItems.Count = 0 Then Exit Sub ' User clicked cancel
strText = .SelectedItems(1)
End With
intUnit = FreeFile
Open strText For Output As intUnit
With Worksheets("Export").UsedRange
For Each rngRow In .Rows
strText = ""
For Each rngCell In rngRow.Cells
If Len(rngCell.Value) = 0 Then Exit For
strText = strText & "" & rngCell.Value
Next
Print #intUnit, (strText)
Next
End With
Close intUnit
End Sub
Hi Alphafrog
how can i amend this code for a powerpoint file?
thisworkbook.path wont work with powerpoint
With Application.FileDialog(msoFileDialogOpen)
.InitialFileName = ThisWorkbook.Path & Application.PathSeparator & "*.txt"
.Title = "Please Select a Text File"
.AllowMultiSelect = False
.Show
If .SelectedItems.Count = 0 Then Exit Sub ' User clicked cancel
strText = .SelectedItems(1)
End With
say i selected a powerpoint presentation, how can i amend accordingly?
I dont want to use thisworkbook .path
i want to have the path and file selected
in the variable
so say i selected a powerpoint slide from a specific folder
i want the variable to give me the full path and filename selected