का उपयोग कर पहुँच में पाठ स्वरूपित मैं एक एक्सेस डेटाबेस में वर्ड से स्वरूपित पाठ को बचाने के लिए की जरूरत है।प्रतिलिपि VBA
अभी तक मैंने यह पता लगाने में कामयाब रहा है कि किसी एक्सेस फ़ील्ड में स्वरूपित टेक्स्ट को कैसे स्टोर किया जाए (तालिका में मेमो फ़ील्ड बनाएं और टेक्स्ट टेक्स्ट को रिच टेक्स्ट के रूप में सेट करें)। अतः मैं अभी तक कैसे परिवहन के लिए के रूप में एक समाधान भर में नहीं आए हैं सर्च कर रहे हैं एक्सेस में शब्द से पाठ कहा।
मुझे पता है कि यह संभव है, क्योंकि आप इसे बस को कॉपी करके करते हैं और जानकारी चिपकाने यदि आप इसे मैन्युअल रूप से कर रहे हैं कर सकते हैं।
मेरा प्रश्न, मैं वीबीए का उपयोग करके तालिका में किसी शब्द में स्वरूपित पाठ को प्रतिलिपि बना सकता हूं?
प्रयोगात्मक मैं इस परीक्षण करने के लिए निम्नलिखित बनाया। अब तक सफलता नहीं मिली ...
Sub GetComments()
'Imports Analyst Comments from Excel files als OLE Objects.
'---------------------------------
'Access Variables
Dim dbsFundDB As DAO.Database
Dim rsComments As DAO.Recordset
Set dbsFundDB = CurrentDb
Set rsComments = dbsFundDB.OpenRecordset("tblFunds")
'Word Variables
Dim doc As Word.Application
Dim dcmt As Word.Document
Dim sectn As Word.Section
Dim obCommentText As Object
Dim sAnalystText As String
'Open New Word File
Set doc = New Word.Application
doc.Visible = True
Set dcmt = doc.Documents.Open(sPathTemplate)
Set sectn = dcmt.Sections(1)
sectn.Range.Select
Selection.InsertFile FileName:="myfile.rtf", Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False
sAnalystText = sectn.Range.Tables(1).cell(1, 1).Range.FormattedText
rsComments.AddNew
rsComments![Long Comment Exec] = sAnalystText
rsComments.Update
sectn.Range.Select
dcmt.Close savechanges:=False
doc.Quit
End Sub
अद्यतन मैं मैट हॉल से जवाब को लागू करने की कोशिश की। पाठ वास्तव में डेटाबेस को कॉपी किया है, लेकिन यह अभी तक स्वरूपण नहीं रखता:
Option Explicit
Public Const sPathTemplate As String = "W:\L\BDTP\Products\FundResearchTool\Advisory.docx"
Option Compare Database
Sub GetComments()
'Imports Comments from word and save in DB
'Test soubroutine
'---------------------------------
'Word Variables
Dim obCommentText As Variant
Dim strSQL As String
obCommentText = GetWordContent(sPathTemplate)
strSQL = "insert into [tblText]([TestField]) values('" & obCommentText & "')"
DoCmd.RunSQL strSQL
MsgBox "Import Successful", vbInformation Or vbOKOnly
End Sub
Private Function GetWordContent(strFile As String) As Variant
' This function takes the path obtained to the MS-Word Document selected in
' the FileToOpen function and then uses that to open that MS-Word Document
' and retrieve its text contents
Dim objDoc As Word.Document
Set objDoc = GetObject(strFile)
GetWordContent = CVar(objDoc.Sections(1).Range.Text)
objDoc.Close
End Function
मैं वास्तव में नहीं है तुम क्या कर रहे साथ अनुभव है । हालांकि मैं इस पोस्ट जो कुछ सभ्य सुझाव है लगता है ढूँढने में सक्षम था: http://stackoverflow.com/questions/14316916/copy-text-from-table-in-word-and-retaing-formatting – Newd