filmov
tv
Excel VBA tutorials to enhance WordPress pages - #1 - Creating data files

Показать описание
Code for Part I see below:
Copy these notes to NotePad and save.
1. Create Microsoft Excel Workbook;
Copy the data for Sheet1 from the video (or create own). Top left cell of table ('First Name'): B6.
Set up a folder 'phpFolder' on your Desktop.
2. Open Excel's Visual Basic Editor, insert a Visual Basic Module and add this sub-routine;
Sub php_TextFiles()
Dim n As Integer
Dim strFirstName As String
Dim strLastName As String
Dim strTown As String
Dim fileName As String
Dim filePath As String
Dim outputText As String
Worksheets("Sheet1").Select
For n = 1 To 5
strFirstName = Cells(6 + n, 2)
strLastName = Cells(6 + n, 3)
strTown = Cells(6 + n, 4)
fileName = strFirstName & "_" & strLastName
' NB: fileName now looks like this: "John_Smith"
' NOTE: adjust the file path below to match your PC folders layout
' NOTE: Youtube 'Description' does not allow HTML characters so change ++ into the opening left pointing bracket and +++ into the closing right pointing bracket (delete this note)
outputText = "Cycling Club member ++b+++" & strFirstName & " " & strLastName & "++/b+++ lives in " & strTown
Open filePath For Output As #1
Print #1, outputText
Close #1
Next
End Sub
3. Download and or activate FileZilla FTP client (or your own choice).
Log on to your WordPress web site and open 'wp-content' directory (directory is same as 'folder' on Windows);
Create New Directory called 'phpFolder' - same name as own PC'
Upload the five text files from 'Desktop\phpFolder' into 'wp-content/phpFolder';
4. Add New Page to your WordPress pages for practice (no links to other pages so unseen by outsiders);
Add and activate Plug-in called 'Insert PHP';
Copy following line in Editor Text View of new page;
Note: square brackets, single quotes, semi-colon and slash in end brackets.
View Page;
Change names in line above and re-load to see different results.
End Part I
Copy these notes to NotePad and save.
1. Create Microsoft Excel Workbook;
Copy the data for Sheet1 from the video (or create own). Top left cell of table ('First Name'): B6.
Set up a folder 'phpFolder' on your Desktop.
2. Open Excel's Visual Basic Editor, insert a Visual Basic Module and add this sub-routine;
Sub php_TextFiles()
Dim n As Integer
Dim strFirstName As String
Dim strLastName As String
Dim strTown As String
Dim fileName As String
Dim filePath As String
Dim outputText As String
Worksheets("Sheet1").Select
For n = 1 To 5
strFirstName = Cells(6 + n, 2)
strLastName = Cells(6 + n, 3)
strTown = Cells(6 + n, 4)
fileName = strFirstName & "_" & strLastName
' NB: fileName now looks like this: "John_Smith"
' NOTE: adjust the file path below to match your PC folders layout
' NOTE: Youtube 'Description' does not allow HTML characters so change ++ into the opening left pointing bracket and +++ into the closing right pointing bracket (delete this note)
outputText = "Cycling Club member ++b+++" & strFirstName & " " & strLastName & "++/b+++ lives in " & strTown
Open filePath For Output As #1
Print #1, outputText
Close #1
Next
End Sub
3. Download and or activate FileZilla FTP client (or your own choice).
Log on to your WordPress web site and open 'wp-content' directory (directory is same as 'folder' on Windows);
Create New Directory called 'phpFolder' - same name as own PC'
Upload the five text files from 'Desktop\phpFolder' into 'wp-content/phpFolder';
4. Add New Page to your WordPress pages for practice (no links to other pages so unseen by outsiders);
Add and activate Plug-in called 'Insert PHP';
Copy following line in Editor Text View of new page;
Note: square brackets, single quotes, semi-colon and slash in end brackets.
View Page;
Change names in line above and re-load to see different results.
End Part I
Комментарии