I am working on an Excel spreadsheet to output to simple BBcode. The codes available are limited, and right now I am only accounting for
, [td], and
. I am new to this and want to add on to the macro to account for basic colors (in this format:
), bold and italics . It would also be great to have a way to have the output automatically copied to the clipboard. I'd appreciate any guidance/suggestions you might have.
This is the macro I have so far:
Thanks!
This is the macro I have so far:
Code:
Option Explicit
Sub MyExport()
Dim RowStart As Integer
Dim ColStart As Integer
Dim ColCount As Integer
Dim RowCount As Integer
Dim RowEnd As Integer
Dim ColEnd As Integer
Dim ctrRow As Integer
Dim ctrCol As Integer
Dim TableName As String
Dim CellString As String
'Get Selection Location and Size
RowStart = Selection.Row
ColStart = Selection.Column
ColCount = Selection.Columns.Count
RowCount = Selection.Rows.Count
RowEnd = RowStart + RowCount - 1
ColEnd = ColStart + ColCount - 1
'Get Table Name
TableName = Sheet1.TextBoxTableName.Text
'Start Table
Sheet1.TextBoxOutput.Text = TableName + "[table=" + Sheet1.TextBoxTableName.Text + "]"
'Make Table Cells
For ctrRow = RowStart To RowEnd
Sheet1.TextBoxOutput.Text = Sheet1.TextBoxOutput.Text + "[tr]"
For ctrCol = ColStart To ColEnd
CellString = Sheet1.Cells(ctrRow, ctrCol).Text
Sheet1.TextBoxOutput.Text = Sheet1.TextBoxOutput.Text + "[td]" + CellString + "[/td]"
Next ctrCol
Sheet1.TextBoxOutput.Text = Sheet1.TextBoxOutput.Text + "[/tr]"
Next ctrRow
'Close Table
Sheet1.TextBoxOutput.Text = Sheet1.TextBoxOutput.Text + "[/table]"
End Sub
Thanks!