English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

What is the best way to output from visual basic a document (with graphics) that you may post on a wall. VB doesn't have to actually print the file, the file is a menu and the meals for the days of the week are stored as string variables.

Is there a program to read the raw RTF formatting of a document? The rtf spec. is quite long and I don't really wish to read it.

2007-07-05 07:03:45 · 2 answers · asked by lansingstudent09101 6 in Computers & Internet Programming & Design

2 answers

You can use MS Word and create a template document which contains some unique strings to do a Find/Replace with and Bookmarks for inserting objects. My template is just an ordinary word document saved in a known location with my application. The program copies this doc and uses automation to perform find/replace.

Using this technique you can use MS Word to layout a template of your own design and use unique tags to locate specific items.

Monday Lunch


In essence you are creating a form letter . (If you don't want to use VB you can use Access to store data (menu items) and perform a mailmerge with Word (form letter))

I used this technique to automate the creation of customized data sheets for some prototype parts using data from Access. The unit Serial Number would be replaced for every occurance of , A book mark was used to locate the insertion point of an Excel chart (also created using a template )


This is a section of code from a module called modDataSheet. There are other functions which create an excell chart which I haven't included. Basically this section shows how to use the MSWord object to do find and replace

(You will have to reference the MS Office & MS Word objects in your project. (Project >> References from main menu)

Public Function CreateDataSheet() As Boolean


Dim NewFileName As String

Dim xlChart As Excel.Chart
Dim chartfound As Boolean

Dim cnt As Integer
Dim shapeCol As Word.Shapes
chartfound = False
CreateDataSheet = False

If Not m_ChartReady Then Exit Function


NewFileName = m_Path & "SN " & m_SN & " Datasheet.doc"

Set m_MSWord = New Word.Application
Set m_XLwbk = GetObject(m_ChartName)

For cnt = 1 To m_XLwbk.Charts.Count
Set xlChart = m_XLwbk.Charts(cnt)
If xlChart.name = "Chart TC" Then
xlChart.Activate

'xlChart.ChartArea.Select
xlChart.SizeWithWindow = False

xlChart.ChartArea.Copy
chartfound = True
Exit For
End If
Next
If Not chartfound Then Exit Function

With m_MSWord
.Application.Visible = True

Set m_MyDoc = .Documents.Open(m_FileName, _
False, _
NotReadOnly, _
DoNotAddToRecentFiles, , , _
Revert, , , , , _
True)

m_MyDoc.Activate
'Using the new Serial number create a copy
'and modify the text to incorporate the new serial number
'
m_MyDoc.SaveAs NewFileName, , , , False, , True, True
m_MyDoc.Activate
'
'Find & Replace
.Selection.Find.ClearFormatting
.Selection.Find.Replacement.ClearFormatting
End With
With m_MSWord.Selection.Find
.Text = ""
.Replacement.Text = m_SN
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
With m_MSWord
.Selection.Find.Execute Replace:=wdReplaceAll
'
'
m_MyDoc.Bookmarks.Item("Chart1InsertPoint").Select
.Selection.PasteSpecial link:=False, DataType:=wdPasteBitmap, _
Placement:=wdInLine

m_MyDoc.SAVE
Set xlChart = Nothing
m_XLwbk.Close False ' do not prompt to save changes
Set m_XLwbk = Nothing
m_MyDoc.Close wdSaveChanges
m_MSWord.Quit
CreateDataSheet = True
End With
End Function


An other technique uses the MS Word object to create the entire document in code. This can get a little hairy as you cannot see the layout until you run it. I have done this when creating receipts or very small reports. it also helps to use a fixed spaced font like Courier New when using this technique to aid in positioning and padding text.

2007-07-05 07:41:30 · answer #1 · answered by MarkG 7 · 0 0

how come intWidth and intLength values are actually not supplied? If those are actually not supplied, the output will continuously be 0. with the aid of the way shouldn't or not it rather is intWidth = txtWidth.text textile intLength = txtLength.text textile rather of txtWidth.text textile = intWidth txtLength.text textile = intLength ? The variable value would desire to be acquired from the Textbox substitute Dim intSquare As Integer to DOUBLE or long. Integer variable can't in fantastic condition super numbers. this might clean up the difficulty

2016-09-29 03:25:36 · answer #2 · answered by Anonymous · 0 0

fedest.com, questions and answers