Re code amendment

Sahil123

Well-known Member
Joined
Oct 31, 2011
Messages
673
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
 

Some videos you may like

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Watch MrExcel Video

Forum statistics

Threads
1,123,478
Messages
5,601,900
Members
414,482
Latest member
morkar

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
Top