![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Microsoft Office support MS Office support forum |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: Oct 2008
Location: Alabama
Posts: 1
OS: Windows XP sp5
|
WordBasic 2003 to 2007
I have macros written back in 1994 but currently working with Microsoft Word 2003 and I want to convert them to Microsoft Word 2007. I'm having problems with some of the WordBasic commands and would like to see the syntax for WordBasic commands available with Microsoft Word 2007. Any help will be greatly appreciated. I'm providing an example of one of the macros in this message:
This is the macor for closing files. Option Explicit Public Sub MAIN() Dim ss$ Dim x Dim x_$ Dim a$ WordBasic.ScreenUpdating (0) WordBasic.FileConfirmConversions 0 ss$ = WordBasic.[WindowName$]() x = WordBasic.CountWindows() While x > 1 WordBasic.NextWindow x_$ = WordBasic.[WindowName$]() If x_$ <> ss$ Then WordBasic.DocClose x = x - 1 Wend Dim dlgz As Object: Set dlgz = WordBasic.DialogRecord.ToolsOptionsView(False) WordBasic.CurValues.ToolsOptionsView dlgz a$ = Str(dlgz.PicturePlaceHolders) WordBasic.SetDocumentVar "picplac$", a$ dlgz.PicturePlaceHolders = 1 WordBasic.ToolsOptionsView dlgz x_$ = WordBasic.[GetDocumentVar$]("prtct$") If x_$ = "y" Then WordBasic.ToolsUnprotectDocument DocumentPassword:="********" WordBasic.DisableAutoMacros WordBasic.ToolsProtectDocument Type:=2, NoReset:=1, DocumentPassword:="********" WordBasic.SetDocumentVar "prtct$", "y" End Sub Private Sub allexit() Dim x Dim x_$ Dim dlgz As Object Dim a$ Dim a_ x = WordBasic.CountWindows() While x > 0 x_$ = WordBasic.[GetDocumentVar$]("prtct$") If x_$ = "y" Then Set dlgz = WordBasic.DialogRecord.ToolsOptionsView(False) WordBasic.CurValues.ToolsOptionsView dlgz a$ = WordBasic.[GetDocumentVar$]("picplac$") a_ = WordBasic.Val(a$) dlgz.PicturePlaceHolders = a_ WordBasic.ToolsOptionsView dlgz WordBasic.ToolsUnprotectDocument DocumentPassword:="********" WordBasic.DisableAutoMacros 0 WordBasic.ToolsProtectDocument Type:=2, NoReset:=1, DocumentPassword:="********" End If WordBasic.NextWindow x = x - 1 Wend End Sub Private Function cderr(msg$) Dim ret Dim z$ Dim pos ret = 0 Open "c:\winword\cdsar.msg" For Input As 1 While Not EOF(1) Line Input #1, z$ pos = InStr(z$, msg$) If pos <> 0 Then ret = 1 Wend Close 1 cderr = ret End Function Private Function godir(dirr$) godir = 0 On Error GoTo -1: On Error GoTo notfound WordBasic.ChDir dirr$ GoTo the_end notfound: WordBasic.MsgBox "Can't change to " + dirr$ On Error GoTo -1: On Error GoTo 0 godir = 1 the_end: End Function Private Function findip$() findip$ = WordBasic.[GetDocumentVar$]("myip$") End Function Private Function fileexists(pth$, fnm$) Dim siz Dim bms$ fileexists = 1 WordBasic.FileFind SearchPath:=pth$, Name:=fnm$ siz = WordBasic.CountFoundFiles() If siz = 0 Then bms$ = "File " + fnm$ + " not found in " + pth$ WordBasic.MsgBox bms$ fileexists = 0 End If End Function Private Function monthpth$() Dim a$ Dim b Dim st Dim c$ a$ = WordBasic.[FileName$]() b = Len(a$) st = 0 While (b > 0) And (st = 0) c$ = Mid(a$, b, 1) If c$ = "\" Then st = 1 b = b - 1 Wend monthpth$ = Mid(a$, 1, b) End Function Private Function altmonthpth$() Dim a$ Dim b Dim d$ Dim p Dim c$ a$ = monthpth$ b = Len(a$) d$ = "" p = 1 While b > 0 c$ = Mid(a$, p, 1) If c$ = "\" Then c$ = "/" d$ = d$ + c$ b = b - 1 p = p + 1 Wend altmonthpth$ = d$ End Function Private Function monthnm$() Dim a$ Dim b Dim d Dim st Dim c$ a$ = WordBasic.[FileName$]() b = Len(a$) d = 0 st = 0 While (b > 0) And (st = 0) c$ = Mid(a$, b, 1) If c$ = "\" Then st = 1 d = d + 1 b = b - 1 Wend monthnm$ = Mid(a$, b + 2, d - 1) End Function Private Sub sleep(seconds) Dim n Dim beepTime n = WordBasic.Second(WordBasic.Now()) beepTime = n + seconds If beepTime > 59 Then beepTime = beepTime - 60 While WordBasic.Second(WordBasic.Now()) <> beepTime Wend WordBasic.Beep End Sub Private Sub padlf(i$, i_) Dim j Dim a$ Dim k j = i_ - Len(i$) If j < 1 Then GoTo fin a$ = "" For k = 1 To j a$ = a$ + " " Next k i$ = a$ + i$ fin: End Sub Private Function padnum$(i, z) Dim i_$ i_$ = WordBasic.[Ltrim$](Str(i)) padlf i_$, z padnum$ = i_$ End Function Public Function padrt$(a$, s) Dim z Dim p Dim c$ Dim d$ Dim b$ z = Len(a$) p = 1 c$ = "" While p < (z + 1) d$ = Mid(a$, p, 1) p = p + 1 If d$ <> " " Then c$ = c$ + d$ Wend b$ = "" z = Len(c$) While z < s b$ = b$ + " " z = z + 1 Wend padrt$ = c$ + b$ End Function Private Function xDate$(x) Dim d Dim m Dim y Dim d_$ Dim m_$ Dim y_$ d = WordBasic.Day(x) m = WordBasic.Month(x) y = WordBasic.Year(x) d_$ = WordBasic.[Ltrim$](Str(d)) If d < 10 Then d_$ = "0" + d_$ If m = 1 Then m_$ = "Jan" If m = 2 Then m_$ = "Feb" If m = 3 Then m_$ = "Mar" If m = 4 Then m_$ = "Apr" If m = 5 Then m_$ = "May" If m = 6 Then m_$ = "Jun" If m = 7 Then m_$ = "Jul" If m = 8 Then m_$ = "Aug" If m = 9 Then m_$ = "Sep" If m = 10 Then m_$ = "Oct" If m = 11 Then m_$ = "Nov" If m = 12 Then m_$ = "Dec" y_$ = y xDate$ = d_$ + " " + m_$ + " " + y_$ End Function Private Function yDate$(x) Dim d Dim m Dim y Dim d_$ Dim m_$ Dim y_$ d = WordBasic.Day(x) m = WordBasic.Month(x) y = WordBasic.Year(x) d_$ = WordBasic.[Ltrim$](Str(d)) If d < 10 Then d_$ = "0" + d_$ If m = 1 Then m_$ = "January" If m = 2 Then m_$ = "February" If m = 3 Then m_$ = "March" If m = 4 Then m_$ = "April" If m = 5 Then m_$ = "May" If m = 6 Then m_$ = "June" If m = 7 Then m_$ = "July" If m = 8 Then m_$ = "August" If m = 9 Then m_$ = "September" If m = 10 Then m_$ = "October" If m = 11 Then m_$ = "November" If m = 12 Then m_$ = "December" y_$ = WordBasic.[Ltrim$](Str(y)) yDate$ = d_$ + " " + m_$ + " " + y_$ End Function Private Sub closz() Dim ss$ Dim x Dim x_$ ss$ = WordBasic.[WindowName$]() x = WordBasic.CountWindows() While x > 1 WordBasic.NextWindow x_$ = WordBasic.[WindowName$]() If x_$ <> ss$ Then WordBasic.DocClose x = x - 1 Wend WordBasic.DisableAutoMacros End Sub Private Sub cexit() WordBasic.DisableAutoMacros 0 End Sub |
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
![]() |
| Thread Tools | |
|
|