neilholmes
10-04-2011, 08:18 AM
Hi all... (Back again). :hi:
I've had some great help from everyone on the forum regarding the reports I am building, but have come up against another problem that I was hoping someone would be able to help me with.
Previously, I have been using OptionButtons built in userforms to help the user add content to a template report. (See thread: http://www.vbaexpress.com/forum/showthread.php?t=37681). This works great for adding single options.
I have now met a situation where there are multiple options for the user.
For example.
From the following list, please select which statements you would like included in your report.
Statement 1
Statement 2
Statement 3
Statement 4
In this example the user will have the option to select 1 + 2 + 3 + 4, 1+4 or any conbination of the options.
So far (like the previous coding) I have looked to built this by importing from other documents. So each statement will have a corresponding .dot file, and there will be a bookmark in place within the template (BookmarkStatement1 for example) to receive the copied content.
The bookmarks (in the template) are stacked on top of each other as follows:
][
][
][
][
I have built some code based on the previous code that if, by using CheckBox's the CheckBox is 'True' the code will copy in the required content to the bookmark. If the CheckBox is 'False' it will copy in blank content.
Dim Doc1 As Document, StrVar1 As String
StrVar1 = ""
If CheckBox1 = True Then
StrVar1 = "1"
ElseIf CheckBox2 = False Then
StrVar1 = "2"
End If
Set Doc1 = Documents.Open("C:\MY DOCUMENTS\STATEMENT" & StrVar1 & ".dot", _
AddToRecentFiles:=False, Visible:=False)
Doc1.Range.Copy
Doc1.Close savechanges:=False
ActiveDocument.Bookmarks("STATEMENT").Range.Paste
Dim Doc1 As Document, StrVar1 As String
StrVar1 = ""
Is there a better way to handle this ? My biggest issues are that when content is pasted in (actual content and blanks), I end up with spaces and a lot of mess between content. For example:
]Statement 1 Text[
][
][
][
][
Any help would be great... And I hope my explanation is clear enough for people to understand.
- Neil
I've had some great help from everyone on the forum regarding the reports I am building, but have come up against another problem that I was hoping someone would be able to help me with.
Previously, I have been using OptionButtons built in userforms to help the user add content to a template report. (See thread: http://www.vbaexpress.com/forum/showthread.php?t=37681). This works great for adding single options.
I have now met a situation where there are multiple options for the user.
For example.
From the following list, please select which statements you would like included in your report.
Statement 1
Statement 2
Statement 3
Statement 4
In this example the user will have the option to select 1 + 2 + 3 + 4, 1+4 or any conbination of the options.
So far (like the previous coding) I have looked to built this by importing from other documents. So each statement will have a corresponding .dot file, and there will be a bookmark in place within the template (BookmarkStatement1 for example) to receive the copied content.
The bookmarks (in the template) are stacked on top of each other as follows:
][
][
][
][
I have built some code based on the previous code that if, by using CheckBox's the CheckBox is 'True' the code will copy in the required content to the bookmark. If the CheckBox is 'False' it will copy in blank content.
Dim Doc1 As Document, StrVar1 As String
StrVar1 = ""
If CheckBox1 = True Then
StrVar1 = "1"
ElseIf CheckBox2 = False Then
StrVar1 = "2"
End If
Set Doc1 = Documents.Open("C:\MY DOCUMENTS\STATEMENT" & StrVar1 & ".dot", _
AddToRecentFiles:=False, Visible:=False)
Doc1.Range.Copy
Doc1.Close savechanges:=False
ActiveDocument.Bookmarks("STATEMENT").Range.Paste
Dim Doc1 As Document, StrVar1 As String
StrVar1 = ""
Is there a better way to handle this ? My biggest issues are that when content is pasted in (actual content and blanks), I end up with spaces and a lot of mess between content. For example:
]Statement 1 Text[
][
][
][
][
Any help would be great... And I hope my explanation is clear enough for people to understand.
- Neil