Franchise1375
New Member
- Joined
- May 19, 2020
- Messages
- 1
- Office Version
- 2016
- Platform
- Windows
Hi. I am very new to vba and need assistance. I am trying to pass a variable from the module to the userform. Can anyone advise? Thank you!
MODULE CODE:
Sub Input_file_path()
nxt:
file_path = InputBox("Enter filepath directory of output files", "")
If file_path = "" Then
'MsgBox "No data was entered, please retry."
'GoTo nxt:
GoTo ext:
Else
Debug.Print file_path
End If
msgbox (file_path)
Exit Sub
ext:
msgbox "You didn't enter anything."
msgbox "Ctrl Break here if you want to exit program."
End Sub
Public month_year As String
Public file_path As String
Sub CommandButton1_Click()
'Worksheets(ListBox1.Value).PrintOut
pdfName = ActiveSheet.Name
ChDir ActiveWorkbook.Path & "\"
fileSaveName = ActiveSheet.Name & month_year
msgbox (fileSaveName)
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
fileSaveName _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
USERFORM CODE:
Public month_year As String
Public file_path As String
Sub CommandButton1_Click()
'Worksheets(ListBox1.Value).PrintOut
pdfName = ActiveSheet.Name
ChDir ActiveWorkbook.Path & "\"
fileSaveName = ActiveSheet.Name & month_year
msgbox (fileSaveName)
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
fileSaveName _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
End Sub
Sub CommandButton_Click()
End Sub
Sub UserForm_Click()
End Sub
Sub UserForm_Initialize()
Dim n As Integer
Do
n = n + 1
ListBox1.AddItem Sheets.Name
Loop Until n = Worksheets.Count
End Sub
MODULE CODE:
Sub Input_file_path()
nxt:
file_path = InputBox("Enter filepath directory of output files", "")
If file_path = "" Then
'MsgBox "No data was entered, please retry."
'GoTo nxt:
GoTo ext:
Else
Debug.Print file_path
End If
msgbox (file_path)
Exit Sub
ext:
msgbox "You didn't enter anything."
msgbox "Ctrl Break here if you want to exit program."
End Sub
Public month_year As String
Public file_path As String
Sub CommandButton1_Click()
'Worksheets(ListBox1.Value).PrintOut
pdfName = ActiveSheet.Name
ChDir ActiveWorkbook.Path & "\"
fileSaveName = ActiveSheet.Name & month_year
msgbox (fileSaveName)
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
fileSaveName _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
USERFORM CODE:
Public month_year As String
Public file_path As String
Sub CommandButton1_Click()
'Worksheets(ListBox1.Value).PrintOut
pdfName = ActiveSheet.Name
ChDir ActiveWorkbook.Path & "\"
fileSaveName = ActiveSheet.Name & month_year
msgbox (fileSaveName)
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
fileSaveName _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
End Sub
Sub CommandButton_Click()
End Sub
Sub UserForm_Click()
End Sub
Sub UserForm_Initialize()
Dim n As Integer
Do
n = n + 1
ListBox1.AddItem Sheets.Name
Loop Until n = Worksheets.Count
End Sub