|
-
Aug 23rd, 2005, 02:06 PM
#1
Thread Starter
Member
MS Word
Hi,
In a VB app i am joining .doc into a master document.when i insert the docs the master the formatting changes sometimes is it possible to insert without affectting the formatting.
adhi
-
Aug 23rd, 2005, 02:37 PM
#2
Re: MS Word
Post your code for inserting.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 23rd, 2005, 02:56 PM
#3
Thread Starter
Member
Re: MS Word
VB Code:
Public Sub DocOpen(ByVal sFile As String, Optional ViewOnly As Variant, Optional AddToRecentFile As Variant)
Dim bViewOnly As Boolean
Dim bAddToRecentFile As Boolean
On Error GoTo ErrorHandler
bViewOnly = False
bAddToRecentFile = False
If Not IsMissing(ViewOnly) Then
bViewOnly = ViewOnly
End If
If Not IsMissing(AddToRecentFile) Then
bAddToRecentFile = AddToRecentFile
End If
Set m_WordDoc = m_WordApp.Documents.Open(sFile, , bViewOnly, bAddToRecentFile)
Set m_WordRange = m_WordDoc.Range
If bViewOnly Then
m_WordApp.ActiveDocument.Protect wdAllowOnlyComments
End If
Exit Sub
-
Aug 23rd, 2005, 03:06 PM
#4
Re: MS Word
So your saying that this line is adding a document to the documents collection and changing the formatting?
VB Code:
Set m_WordDoc = m_WordApp.Documents.Open(sFile, , bViewOnly, bAddToRecentFile)
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 23rd, 2005, 03:42 PM
#5
Thread Starter
Member
Re: MS Word
sorry i sent you the wrong code.
VB Code:
Public Sub DocAdd(ByVal sDocfile As String)
Dim lEndDoc As Long
lEndDoc = m_WordRange.End
With m_WordApp.Selection
.Move unit:=wdCharacter, Count:=lEndDoc
.InsertBreak wdSectionBreakNextPage
.Collapse Direction:=wdCollapseEnd
.InsertFile sDocfile, , , True
Set m_WordRange = m_WordDoc.Range(lEndDoc, m_WordDoc.Range.End)
End With
End Sub
-
Aug 23rd, 2005, 05:35 PM
#6
Re: MS Word
What if you did a copy/paste? It would then retain the formatting/coloring etc. but then you would have to code in the opening and selection and copying of the to be pasted document.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 24th, 2005, 10:34 AM
#7
Thread Starter
Member
Re: MS Word
Yeah...instead Of Inserting File..i May Copy And Paste...that Might Work...let Me Try.
Thanks
-
Sep 6th, 2005, 03:37 PM
#8
Thread Starter
Member
Re: MS Word
I tried doing it...i dont exactly to do it..
need help
-
Sep 7th, 2005, 12:32 AM
#9
Re: MS Word
Post your code and what is going on.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 7th, 2005, 07:50 AM
#10
Thread Starter
Member
Re: MS Word
You suggested ..that instead of inserting file to the master document, to copy/paste. But i dont know exactly how to do it. i tried opening the doc to copy the contents for copy paste...but i dont know how to do it.
the code i posted earlier is the one i used to insert docs into the master document.
adhi
-
Sep 7th, 2005, 10:49 PM
#11
Re: MS Word
You open another document and select the entire document. Then paste it into the current position in your master document.
Just the basics ...
VB Code:
'Select the entire doc
Dim oDoc As Word.Document
Set oDoc = m_WordApp.Documents.Open("C:\SomeOtherFile.doc")
oDoc.Activate
m_WordApp.Selection.WholeStory
m_WordApp.Selection.CopyFormat 'Or Selection.Copy
m_WordApp.Documents("MasterDocName").Activate
m_WordApp.Paste' Or PasteFormat
'Close the other document, etc.
oDoc.Close False
Set oDoc = Nothing
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|