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
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,282
Messages
5,836,396
Members
430,425
Latest member
xlsee

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