|
-
Mar 24th, 2006, 11:13 AM
#1
Thread Starter
Member
[RESOLVED] VB newbie needs help
hi everyone!thanks for reading my thread hope that u can help me with VB
ok the problem is like this.i have a word document that i would like to edit and save its content by using VB programming tools.th data in the word doc are like this
p01=100
p02=150
p03=200
and so on.so is there anyway for me to edit its value and at the same time save this edited version via VB programming tools that i wanna build?
thanks!
-
Mar 24th, 2006, 11:15 AM
#2
Re: VB newbie needs help
Welcome to the Forums.
You are using what version of VB? VB6, VB.NET 2002/2003/2005/Express?
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 
-
Mar 24th, 2006, 11:29 AM
#3
Thread Starter
Member
Re: VB newbie needs help
oh sorry forgot to mention that
im using vb 6
-
Mar 24th, 2006, 11:45 AM
#4
Re: VB newbie needs help
Easiest way then is to record a macro doing your tasks and then stop recording, check the vba macro generated code in the VBA IDE (Alt_F11) and convert it into VB6.
VB Code:
Option explicit
'Add a reference to ms word xx.0 object library
Private sub command1_click()
dim oApp as word.application
dim odoc as word.document
set oapp = new word.application
set odoc = oapp.documents.open("C:\mydoc.doc")
'Then convert the macro code and inser here.
'Should be using the .Find and Replace meth0ds
odoc.save
odoc.close
set odoc = nothing
oapp.quit
set oapp = nothing
end sub
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 
-
Mar 29th, 2006, 02:59 AM
#5
Thread Starter
Member
Re: VB newbie needs help
thanks ROb for the reply!really appreciate it.
but since i'm so very new at this (VB that is) so i don't quite understand the way that you proposed (the macro).
the pics below is the way i wanted to do
referring to the figure, i want to edit a text or excel files inside VB programming.i should be able to open the file via VB as in the pics, edit it there and save it back into the folder.i really hope could do it like that but have no idea how to do it.i'm thinking of using OLE but didn't know how.please help!
thanks!
-
Mar 29th, 2006, 08:05 AM
#6
Re: VB newbie needs help
The Save button will be like the code example I already posted. the New button will be similar but with this line - set odoc = oapp.documents.add.
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 
-
Mar 29th, 2006, 11:17 PM
#7
Thread Starter
Member
Re: VB newbie needs help
Option Explicit
Private Sub cmdNew_Click()
OLE1.CreateEmbed "", "Word.Document"
OLE1.DoVerb vbOLEUIActivate
OLE1.SizeMode = 1
With OLE1.object
.ActiveWindow.DisplayVerticalScrollbar = True
.ActiveWindow.DisplayHorizontalScrollbar = True
End With
End Sub
____________________________________________________________
so i have learn to open a new word doc in OLE window.but i want to open a document not create new one.Can you direct me how to do it?
____________________________________________________________
Private Sub mnuSaveAs_Click()
'Display the Save As Dialog Box
dlgCommon.ShowSave 'Display the Save As dialog box
End Sub
Private Sub mnuOpen_Click()
'Display the Open Dialog Box
dlgCommon.ShowOpen 'Display the Open dialog box
End Sub
_____________________________________________________________
referring to common dialog box tutorial, i found out that this command will open the dialog bo but how to use it to open a word document inside the OLE window then using the save as button to save the document after i've finish editing it?
thanks!
-
Mar 30th, 2006, 05:27 AM
#8
Re: VB newbie needs help
Heres an example of creating a linked ole object on an existing word document.
VB Code:
Private Sub cmdOpen_Click()
dlgCommon.ShowOpen
OLE1.CreateLink dlgCommon.FileName, "Word.Document"
OLE1.DoVerb vbOLEOpen
End Sub
Once the linked document is linked you can coninue to open it or double click on the ole control to invoke the verb open command.
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 
-
Mar 30th, 2006, 09:33 AM
#9
Thread Starter
Member
Re: VB newbie needs help
ok i do what you've said but that only lets me to open microsoft word when i click "open".is there any way to open the document inside the OLE frame,(in other words it will not run microsoft word but open the document inside vb itself) the i can edit it inside the OLE window?
thanks!
-
Mar 30th, 2006, 11:02 AM
#10
Re: VB newbie needs help
Probably change it to .CreateEmbed
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 
-
Mar 30th, 2006, 10:02 PM
#11
Thread Starter
Member
Re: VB newbie needs help
change the OLE1.CreateLink to OLE1.CreateEmbed ?
-
Mar 31st, 2006, 08:25 AM
#12
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 
-
Mar 31st, 2006, 09:06 AM
#13
Thread Starter
Member
Re: VB newbie needs help
yep i did try it but but it said run time error '424'
-
Mar 31st, 2006, 09:21 AM
#14
Re: VB newbie needs help
Hmm, try this.
VB Code:
Option Explicit
Private Sub Form_Load()
OLE1.CreateEmbed "D:\Test.doc", "Word.Application"
OLE1.OLETypeAllowed = vbOLEEither
OLE1.SizeMode = 0
OLE1.DisplayType = 0
OLE1.UpdateOptions = 0
End Sub
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 
-
Mar 31st, 2006, 08:40 PM
#15
Thread Starter
Member
Re: VB newbie needs help
hmm now its compile error variarble not defined
hey rob how bout opening excel but still like the way i asked you?is it easier?since word doesn't really suit to be a database anyway so how's excel?
thanks!
-
Mar 31st, 2006, 08:43 PM
#16
Re: VB newbie needs help
Not sure why you are having these issues. Do you have service pack 6 for VB or VS installed too?
To use Excel just change the class type to "Excel.Application"
OLE1.CreateEmbed "D:\Test.xls", "Excel.Application"
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 
-
Apr 1st, 2006, 12:55 AM
#17
Thread Starter
Member
Re: VB newbie needs help
okay ill try it first
one more thing do i have to put a OLE (excel) window on the form?
-
Apr 1st, 2006, 02:03 AM
#18
Re: VB newbie needs help
Absolutely or else your not using it.
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 
-
Apr 1st, 2006, 09:15 PM
#19
Thread Starter
Member
Re: VB newbie needs help
hey rob do you know how to browse pics in vb and save it in a database?i know browse using common control but i cant open it in vb.And how do i open a unigraphics drawing file via vb?to automatically run unigraphics of course (unigraphics is a CAD software)
Last edited by posto; Apr 1st, 2006 at 11:43 PM.
-
Apr 2nd, 2006, 09:38 AM
#20
Re: VB newbie needs help
Probably would be better to start a new thread on this. 
Dont forget to mention which db your using and version etc.
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 
-
Apr 2nd, 2006, 09:13 PM
#21
Thread Starter
Member
Re: VB newbie needs help
ok! thanks for your help rob!
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
|